From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 08:17:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1651C106568C; Sun, 29 Apr 2012 08:17:45 +0000 (UTC) (envelope-from jlh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0190F8FC08; Sun, 29 Apr 2012 08:17:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3T8Hi7O004494; Sun, 29 Apr 2012 08:17:44 GMT (envelope-from jlh@svn.freebsd.org) Received: (from jlh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T8HiUI004492; Sun, 29 Apr 2012 08:17:44 GMT (envelope-from jlh@svn.freebsd.org) Message-Id: <201204290817.q3T8HiUI004492@svn.freebsd.org> From: Jeremie Le Hen Date: Sun, 29 Apr 2012 08:17:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234779 - head/usr.bin/stdbuf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 08:17:45 -0000 Author: jlh Date: Sun Apr 29 08:17:44 2012 New Revision: 234779 URL: http://svn.freebsd.org/changeset/base/234779 Log: Use standard getopt(3) error message. Submitted by: jilles Approved by: kib (mentor) Modified: head/usr.bin/stdbuf/stdbuf.c Modified: head/usr.bin/stdbuf/stdbuf.c ============================================================================== --- head/usr.bin/stdbuf/stdbuf.c Sun Apr 29 00:59:38 2012 (r234778) +++ head/usr.bin/stdbuf/stdbuf.c Sun Apr 29 08:17:44 2012 (r234779) @@ -52,7 +52,7 @@ main(int argc, char *argv[]) int i; ibuf = obuf = ebuf = NULL; - while ((i = getopt(argc, argv, ":e:i:o:")) != -1) { + while ((i = getopt(argc, argv, "e:i:o:")) != -1) { switch (i) { case 'e': ebuf = optarg; @@ -63,13 +63,8 @@ main(int argc, char *argv[]) case 'o': obuf = optarg; break; - case ':': - warnx("Missing argument for option -%c", optopt); - usage(1); - break; case '?': default: - warnx("Unknown option: %c", optopt); usage(1); break; } From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 09:32:44 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F028D106564A; Sun, 29 Apr 2012 09:32:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D7E178FC08; Sun, 29 Apr 2012 09:32:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3T9WiLk007200; Sun, 29 Apr 2012 09:32:44 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T9Wi90007188; Sun, 29 Apr 2012 09:32:44 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204290932.q3T9Wi90007188@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 29 Apr 2012 09:32:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234782 - in head: gnu/usr.bin/binutils/ar gnu/usr.bin/binutils/as gnu/usr.bin/binutils/ld gnu/usr.bin/binutils/ranlib gnu/usr.bin/cc/cc gnu/usr.bin/cc/cc1 gnu/usr.bin/cc/cc1plus share/... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 09:32:45 -0000 Author: kib Date: Sun Apr 29 09:32:44 2012 New Revision: 234782 URL: http://svn.freebsd.org/changeset/base/234782 Log: Add src.conf option WITH_SHARED_TOOLCHAIN to enable building the toolchain binaries as dynamically linked. Option is disabled by default. Reviewed by: ru (previous version) MFC after: 2 weeks Added: head/tools/build/options/WITH_SHARED_TOOLCHAIN (contents, props changed) Modified: head/gnu/usr.bin/binutils/ar/Makefile head/gnu/usr.bin/binutils/as/Makefile head/gnu/usr.bin/binutils/ld/Makefile head/gnu/usr.bin/binutils/ranlib/Makefile head/gnu/usr.bin/cc/cc/Makefile head/gnu/usr.bin/cc/cc1/Makefile head/gnu/usr.bin/cc/cc1plus/Makefile head/share/mk/bsd.own.mk head/usr.bin/ar/Makefile head/usr.bin/make/Makefile Modified: head/gnu/usr.bin/binutils/ar/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/ar/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/ar/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,7 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include .PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc @@ -16,7 +17,9 @@ CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils CFLAGS+= -I${SRCDIR}/binutils CFLAGS+= -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbinutils/libbinutils.a DPADD+= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a Modified: head/gnu/usr.bin/binutils/as/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/as/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/as/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -4,6 +4,7 @@ # BINDIR .include "${.CURDIR}/../../Makefile.inc" .include "${.CURDIR}/../Makefile.inc0" +.include .PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config @@ -79,7 +80,9 @@ CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${SRCDIR}/gas -I${SRCDIR}/bfd -I${SRCDIR}/gas/config -I${SRCDIR} CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${TARGET_CPUARCH}-freebsd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a Modified: head/gnu/usr.bin/binutils/ld/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/ld/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/ld/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,7 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include .PATH: ${SRCDIR}/ld @@ -34,7 +35,9 @@ CFLAGS+= -DBINDIR=\"${BINDIR}\" -DTARGET CFLAGS+= -DTOOLBINDIR=\"${TOOLS_PREFIX}/${BINDIR}/libexec\" CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a LDADD= ${DPADD} Modified: head/gnu/usr.bin/binutils/ranlib/Makefile ============================================================================== --- head/gnu/usr.bin/binutils/ranlib/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/binutils/ranlib/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,7 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include .PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc @@ -16,7 +17,9 @@ CFLAGS+= -D_GNU_SOURCE CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils CFLAGS+= -I${SRCDIR}/binutils CFLAGS+= -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif DPADD= ${RELTOP}/libbinutils/libbinutils.a DPADD+= ${RELTOP}/libbfd/libbfd.a DPADD+= ${RELTOP}/libiberty/libiberty.a Modified: head/gnu/usr.bin/cc/cc/Makefile ============================================================================== --- head/gnu/usr.bin/cc/cc/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/cc/cc/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -9,7 +9,9 @@ PROG= gcc MAN= gcc.1 SRCS+= gccspec.c +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?=yes +.endif MLINKS= gcc.1 g++.1 .if ${MK_CLANG_IS_CC} == "no" Modified: head/gnu/usr.bin/cc/cc1/Makefile ============================================================================== --- head/gnu/usr.bin/cc/cc1/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/cc/cc1/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,14 +1,17 @@ # $FreeBSD$ .include "../Makefile.inc" +NO_MAN= +.include .PATH: ${GCCDIR} PROG= cc1 SRCS= main.c c-parser.c c-lang.c BINDIR= /usr/libexec -NO_MAN= +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?=yes +.endif OBJS+= ${PROG}-checksum.o DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} Modified: head/gnu/usr.bin/cc/cc1plus/Makefile ============================================================================== --- head/gnu/usr.bin/cc/cc1plus/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/gnu/usr.bin/cc/cc1plus/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,6 +1,8 @@ # $FreeBSD$ .include "../Makefile.inc" +NO_MAN= +.include .PATH: ${GCCDIR}/cp ${GCCDIR} @@ -13,8 +15,9 @@ SRCS+= main.c cp-lang.c c-opts.c call.c cp-objcp-common.c cp-gimplify.c tree-mudflap.c BINDIR= /usr/libexec -NO_MAN= +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?=yes +.endif CFLAGS+= -I${GCCDIR}/cp -I. Modified: head/share/mk/bsd.own.mk ============================================================================== --- head/share/mk/bsd.own.mk Sun Apr 29 08:51:06 2012 (r234781) +++ head/share/mk/bsd.own.mk Sun Apr 29 09:32:44 2012 (r234782) @@ -425,7 +425,8 @@ __DEFAULT_NO_OPTIONS = \ ICONV \ IDEA \ LIBCPLUSPLUS \ - OFED + OFED \ + SHARED_TOOLCHAIN # # Default behaviour of some options depends on the architecture. Unfortunately Added: head/tools/build/options/WITH_SHARED_TOOLCHAIN ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/build/options/WITH_SHARED_TOOLCHAIN Sun Apr 29 09:32:44 2012 (r234782) @@ -0,0 +1,6 @@ +.\" $FreeBSD$ +Set to build the toolchain binaries shared. +The set includes +.Xr cc 1 , +.Xr make 1 +and neccessary utilites like assembler, linker and library archive manager. Modified: head/usr.bin/ar/Makefile ============================================================================== --- head/usr.bin/ar/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/usr.bin/ar/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + PROG= ar SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h @@ -8,7 +10,9 @@ LDADD= -larchive -lelf CFLAGS+=-I. -I${.CURDIR} +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes +.endif LINKS= ${BINDIR}/ar ${BINDIR}/ranlib MLINKS= ar.1 ranlib.1 Modified: head/usr.bin/make/Makefile ============================================================================== --- head/usr.bin/make/Makefile Sun Apr 29 08:51:06 2012 (r234781) +++ head/usr.bin/make/Makefile Sun Apr 29 09:32:44 2012 (r234782) @@ -2,13 +2,17 @@ # $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $ # $FreeBSD$ +.include + PROG= make CFLAGS+=-I${.CURDIR} SRCS= arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c \ lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c \ util.c var.c +.if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= YES +.endif # Version has the RYYYYMMDDX format, where R is from RELENG_ CFLAGS+=-DMAKE_VERSION=\"5201111300\" From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 09:37:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6E5341065679; Sun, 29 Apr 2012 09:37:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 40A078FC14; Sun, 29 Apr 2012 09:37:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3T9b3Ab007395; Sun, 29 Apr 2012 09:37:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3T9b3nA007393; Sun, 29 Apr 2012 09:37:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204290937.q3T9b3nA007393@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 29 Apr 2012 09:37:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234783 - head/share/man/man5 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 09:37:03 -0000 Author: kib Date: Sun Apr 29 09:37:02 2012 New Revision: 234783 URL: http://svn.freebsd.org/changeset/base/234783 Log: Regenerate src.conf(5) Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Sun Apr 29 09:32:44 2012 (r234782) +++ head/share/man/man5/src.conf.5 Sun Apr 29 09:37:02 2012 (r234783) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 221733 2011-05-10 13:01:11Z ru .\" $FreeBSD$ -.Dd March 25, 2012 +.Dd April 29, 2012 .Dt SRC.CONF 5 .Os .Sh NAME @@ -270,7 +270,7 @@ When set, it also enforces the following Set to not build the Clang C/C++ compiler. .Pp It is a default setting on -arm/arm, arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64. +arm/arm, arm/armeb, ia64/ia64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc and sparc64/sparc64. When set, it also enforces the following options: .Pp .Bl -item -compact @@ -284,7 +284,7 @@ When set, it also enforces the following Set to build the Clang C/C++ compiler. .Pp It is a default setting on -amd64/amd64, i386/i386, pc98/i386, powerpc/powerpc and powerpc/powerpc64. +amd64/amd64, i386/i386, pc98/i386 and powerpc/powerpc64. .It Va WITH_CLANG_EXTRAS .\" from FreeBSD: head/tools/build/options/WITH_CLANG_EXTRAS 231057 2012-02-05 23:56:22Z dim Set to build additional clang and llvm tools, such as bugpoint. @@ -891,6 +891,13 @@ as a set-user-ID root program. Set to not build the .Bx 4.4 legacy docs. +.It Va WITH_SHARED_TOOLCHAIN +.\" from FreeBSD: head/tools/build/options/WITH_SHARED_TOOLCHAIN 234782 2012-04-29 09:32:44Z kib +Set to build the toolchain binaries shared. +The set includes +.Xr cc 1 , +.Xr make 1 +and neccessary utilites like assembler, linker and library archive manager. .It Va WITHOUT_SOURCELESS .\" from FreeBSD: head/tools/build/options/WITHOUT_SOURCELESS 230972 2012-02-04 00:54:43Z rmh Set to not build kernel modules that include sourceless code (either microcode or native code for host CPU). From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 11:04:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 46703106564A; Sun, 29 Apr 2012 11:04:32 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EAB68FC0A; Sun, 29 Apr 2012 11:04:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TB4W1T011293; Sun, 29 Apr 2012 11:04:32 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TB4VbQ011280; Sun, 29 Apr 2012 11:04:31 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201204291104.q3TB4VbQ011280@svn.freebsd.org> From: Dimitry Andric Date: Sun, 29 Apr 2012 11:04:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234785 - in head: include sys/amd64/include sys/arm/include sys/i386/include sys/ia64/include sys/mips/include sys/powerpc/include sys/sparc64/include sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 11:04:32 -0000 Author: dim Date: Sun Apr 29 11:04:31 2012 New Revision: 234785 URL: http://svn.freebsd.org/changeset/base/234785 Log: Add a convenience macro for the returns_twice attribute, and apply it to the prototypes of the appropriate functions (getcontext, savectx, setjmp, sigsetjmp and vfork). MFC after: 2 weeks Modified: head/include/setjmp.h head/include/unistd.h head/sys/amd64/include/pcb.h head/sys/arm/include/pcb.h head/sys/i386/include/pcb.h head/sys/ia64/include/pcb.h head/sys/mips/include/pcb.h head/sys/powerpc/include/cpu.h head/sys/sparc64/include/pcb.h head/sys/sys/cdefs.h head/sys/sys/systm.h head/sys/sys/ucontext.h Modified: head/include/setjmp.h ============================================================================== --- head/include/setjmp.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/include/setjmp.h Sun Apr 29 11:04:31 2012 (r234785) @@ -46,16 +46,16 @@ __BEGIN_DECLS #if __BSD_VISIBLE || __XSI_VISIBLE >= 600 void _longjmp(jmp_buf, int) __dead2; -int _setjmp(jmp_buf); +int _setjmp(jmp_buf) __returns_twice; #endif void longjmp(jmp_buf, int) __dead2; #if __BSD_VISIBLE void longjmperror(void); #endif -int setjmp(jmp_buf); +int setjmp(jmp_buf) __returns_twice; #if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE void siglongjmp(sigjmp_buf, int) __dead2; -int sigsetjmp(sigjmp_buf, int); +int sigsetjmp(sigjmp_buf, int) __returns_twice; #endif __END_DECLS Modified: head/include/unistd.h ============================================================================== --- head/include/unistd.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/include/unistd.h Sun Apr 29 11:04:31 2012 (r234785) @@ -479,7 +479,7 @@ char *getwd(char *); /* obsoleted by g useconds_t ualarm(useconds_t, useconds_t); int usleep(useconds_t); -pid_t vfork(void); +pid_t vfork(void) __returns_twice; #endif #if __BSD_VISIBLE Modified: head/sys/amd64/include/pcb.h ============================================================================== --- head/sys/amd64/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/amd64/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -130,7 +130,7 @@ clear_pcb_flags(struct pcb *pcb, const u } void makectx(struct trapframe *, struct pcb *); -int savectx(struct pcb *); +int savectx(struct pcb *) __returns_twice; #endif Modified: head/sys/arm/include/pcb.h ============================================================================== --- head/sys/arm/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/arm/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -94,7 +94,7 @@ void makectx(struct trapframe *tf, struc #ifdef _KERNEL -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif /* _KERNEL */ #endif /* !_MACHINE_PCB_H_ */ Modified: head/sys/i386/include/pcb.h ============================================================================== --- head/sys/i386/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/i386/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -84,7 +84,7 @@ struct pcb { struct trapframe; void makectx(struct trapframe *, struct pcb *); -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif #endif /* _I386_PCB_H_ */ Modified: head/sys/ia64/include/pcb.h ============================================================================== --- head/sys/ia64/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/ia64/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -65,10 +65,10 @@ struct trapframe; void makectx(struct trapframe *, struct pcb *); void restorectx(struct pcb *) __dead2; -int swapctx(struct pcb *old, struct pcb *new); +int swapctx(struct pcb *old, struct pcb *new) __returns_twice; void ia32_restorectx(struct pcb *); -void ia32_savectx(struct pcb *); +void ia32_savectx(struct pcb *) __returns_twice; #endif Modified: head/sys/mips/include/pcb.h ============================================================================== --- head/sys/mips/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/mips/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -78,7 +78,7 @@ struct pcb extern struct pcb *curpcb; /* the current running pcb */ void makectx(struct trapframe *, struct pcb *); -int savectx(struct pcb *); +int savectx(struct pcb *) __returns_twice; #endif #endif /* !_MACHINE_PCB_H_ */ Modified: head/sys/powerpc/include/cpu.h ============================================================================== --- head/sys/powerpc/include/cpu.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/powerpc/include/cpu.h Sun Apr 29 11:04:31 2012 (r234785) @@ -99,6 +99,6 @@ void fork_trampoline(void); void swi_vm(void *); /* XXX the following should not be here. */ -void savectx(struct pcb *); +void savectx(struct pcb *) __returns_twice; #endif /* _MACHINE_CPU_H_ */ Modified: head/sys/sparc64/include/pcb.h ============================================================================== --- head/sys/sparc64/include/pcb.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sparc64/include/pcb.h Sun Apr 29 11:04:31 2012 (r234785) @@ -55,7 +55,7 @@ struct pcb { #ifdef _KERNEL void makectx(struct trapframe *tf, struct pcb *pcb); -int savectx(struct pcb *pcb); +int savectx(struct pcb *pcb) __returns_twice; #endif #endif /* !LOCORE */ Modified: head/sys/sys/cdefs.h ============================================================================== --- head/sys/sys/cdefs.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sys/cdefs.h Sun Apr 29 11:04:31 2012 (r234785) @@ -293,6 +293,12 @@ #define __nonnull(x) #endif +#if __GNUC_PREREQ__(4, 1) +#define __returns_twice __attribute__((__returns_twice__)) +#else +#define __returns_twice +#endif + /* XXX: should use `#if __STDC_VERSION__ < 199901'. */ #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) #define __func__ NULL Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sys/systm.h Sun Apr 29 11:04:31 2012 (r234785) @@ -153,7 +153,7 @@ struct uio; struct _jmp_buf; struct trapframe; -int setjmp(struct _jmp_buf *); +int setjmp(struct _jmp_buf *) __returns_twice; void longjmp(struct _jmp_buf *, int) __dead2; int dumpstatus(vm_offset_t addr, off_t count); int nullop(void); Modified: head/sys/sys/ucontext.h ============================================================================== --- head/sys/sys/ucontext.h Sun Apr 29 10:04:20 2012 (r234784) +++ head/sys/sys/ucontext.h Sun Apr 29 11:04:31 2012 (r234785) @@ -71,7 +71,7 @@ struct ucontext4 { __BEGIN_DECLS -int getcontext(ucontext_t *); +int getcontext(ucontext_t *) __returns_twice; ucontext_t *getcontextx(void); int setcontext(const ucontext_t *); void makecontext(ucontext_t *, void (*)(void), int, ...); From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 12:48:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DE0F5106566C; Sun, 29 Apr 2012 12:48:52 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C8C508FC15; Sun, 29 Apr 2012 12:48:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TCmqVV014786; Sun, 29 Apr 2012 12:48:52 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TCmqGk014783; Sun, 29 Apr 2012 12:48:52 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201204291248.q3TCmqGk014783@svn.freebsd.org> From: Bernhard Schmidt Date: Sun, 29 Apr 2012 12:48:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234786 - in head/usr.sbin/wpa: hostapd wpa_supplicant X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 12:48:53 -0000 Author: bschmidt Date: Sun Apr 29 12:48:52 2012 New Revision: 234786 URL: http://svn.freebsd.org/changeset/base/234786 Log: Fix WITHOUT_EXAMPLES build: While removing unnecessary entries from .PATH.c I missed that for the examples WPA_SUPPLICANT_DISTDIR/HOSTAPD_DISTDIR is explicitly added to .PATH. Tested by: lev MFC after: 2 weeks Modified: head/usr.sbin/wpa/hostapd/Makefile head/usr.sbin/wpa/wpa_supplicant/Makefile Modified: head/usr.sbin/wpa/hostapd/Makefile ============================================================================== --- head/usr.sbin/wpa/hostapd/Makefile Sun Apr 29 11:04:31 2012 (r234785) +++ head/usr.sbin/wpa/hostapd/Makefile Sun Apr 29 12:48:52 2012 (r234786) @@ -2,7 +2,8 @@ .include "${.CURDIR}/../Makefile.inc" -.PATH.c:${WPA_DISTDIR}/src/drivers +.PATH.c:${HOSTAPD_DISTDIR} \ + ${WPA_DISTDIR}/src/drivers PROG= hostapd SRCS= accounting.c \ Modified: head/usr.sbin/wpa/wpa_supplicant/Makefile ============================================================================== --- head/usr.sbin/wpa/wpa_supplicant/Makefile Sun Apr 29 11:04:31 2012 (r234785) +++ head/usr.sbin/wpa/wpa_supplicant/Makefile Sun Apr 29 12:48:52 2012 (r234786) @@ -2,7 +2,8 @@ .include "${.CURDIR}/../Makefile.inc" -.PATH.c:${WPA_DISTDIR}/src/drivers +.PATH.c:${WPA_SUPPLICANT_DISTDIR} \ + ${WPA_DISTDIR}/src/drivers PROG= wpa_supplicant SRCS= aes-unwrap.c \ From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 15:54:41 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13DE0106566B; Sun, 29 Apr 2012 15:54:41 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F324B8FC14; Sun, 29 Apr 2012 15:54:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TFseAo020639; Sun, 29 Apr 2012 15:54:40 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TFsemi020637; Sun, 29 Apr 2012 15:54:40 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201204291554.q3TFsemi020637@svn.freebsd.org> From: Marius Strobl Date: Sun, 29 Apr 2012 15:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234789 - head/sys/boot/common X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 15:54:41 -0000 Author: marius Date: Sun Apr 29 15:54:40 2012 New Revision: 234789 URL: http://svn.freebsd.org/changeset/base/234789 Log: Add multiple inclusion protection. PR: 165025 Submitted by: Gavin Mu MFC after: 1 week Modified: head/sys/boot/common/bootstrap.h Modified: head/sys/boot/common/bootstrap.h ============================================================================== --- head/sys/boot/common/bootstrap.h Sun Apr 29 13:37:32 2012 (r234788) +++ head/sys/boot/common/bootstrap.h Sun Apr 29 15:54:40 2012 (r234789) @@ -26,6 +26,9 @@ * $FreeBSD$ */ +#ifndef _BOOTSTRAP_H_ +#define _BOOTSTRAP_H_ + #include #include #include @@ -323,3 +326,5 @@ void delay(int delay); void dev_cleanup(void); time_t time(time_t *tloc); + +#endif /* !_BOOTSTRAP_H_ */ From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 16:14:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C974E106566B; Sun, 29 Apr 2012 16:14:09 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4B938FC0C; Sun, 29 Apr 2012 16:14:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TGE9RX021401; Sun, 29 Apr 2012 16:14:09 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGE9Ws021398; Sun, 29 Apr 2012 16:14:09 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201204291614.q3TGE9Ws021398@svn.freebsd.org> From: Marius Strobl Date: Sun, 29 Apr 2012 16:14:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234792 - head/sys/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:14:09 -0000 Author: marius Date: Sun Apr 29 16:14:09 2012 New Revision: 234792 URL: http://svn.freebsd.org/changeset/base/234792 Log: Drag in subr_acl_nfs4.c for ZFS automatically, otherwise it's unintuitive that "options zfs" requires "options ufs_acl". Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Apr 29 16:12:31 2012 (r234791) +++ head/sys/conf/files Sun Apr 29 16:14:09 2012 (r234792) @@ -2553,7 +2553,7 @@ kern/sched_ule.c optional sched_ule kern/serdev_if.m standard kern/stack_protector.c standard \ compile-with "${NORMAL_C:N-fstack-protector*}" -kern/subr_acl_nfs4.c optional ufs_acl +kern/subr_acl_nfs4.c optional ufs_acl | zfs kern/subr_acl_posix1e.c optional ufs_acl kern/subr_autoconf.c standard kern/subr_blist.c standard From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 16:21:47 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE045106566B; Sun, 29 Apr 2012 16:21:47 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A8E328FC20; Sun, 29 Apr 2012 16:21:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TGLla6021779; Sun, 29 Apr 2012 16:21:47 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGLl18021777; Sun, 29 Apr 2012 16:21:47 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201204291621.q3TGLl18021777@svn.freebsd.org> From: Marius Strobl Date: Sun, 29 Apr 2012 16:21:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234795 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:21:47 -0000 Author: marius Date: Sun Apr 29 16:21:47 2012 New Revision: 234795 URL: http://svn.freebsd.org/changeset/base/234795 Log: Partially revert r232938; ZFS only requires nfs4 but not posix1e. Submitted by: jhb Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Apr 29 16:20:29 2012 (r234794) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Apr 29 16:21:47 2012 (r234795) @@ -5424,4 +5424,3 @@ DECLARE_MODULE(zfsctrl, zfs_mod, SI_SUB_ MODULE_DEPEND(zfsctrl, opensolaris, 1, 1, 1); MODULE_DEPEND(zfsctrl, krpc, 1, 1, 1); MODULE_DEPEND(zfsctrl, acl_nfs4, 1, 1, 1); -MODULE_DEPEND(zfsctrl, acl_posix1e, 1, 1, 1); From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 16:28:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 448B1106564A; Sun, 29 Apr 2012 16:28:40 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2E76A8FC0C; Sun, 29 Apr 2012 16:28:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TGSeOm022205; Sun, 29 Apr 2012 16:28:40 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TGSdlr022201; Sun, 29 Apr 2012 16:28:39 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201204291628.q3TGSdlr022201@svn.freebsd.org> From: David Schultz Date: Sun, 29 Apr 2012 16:28:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234799 - head/lib/libc/stdio X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 16:28:40 -0000 Author: das Date: Sun Apr 29 16:28:39 2012 New Revision: 234799 URL: http://svn.freebsd.org/changeset/base/234799 Log: Previously, vfscanf()'s wide character processing functions were reading wide characters manually. With this change, they now use fgetwc(). To make this work, we use an internal version of fgetwc() with a few extensions: it takes an mbstate * because non-wide streams don't have a built-in mbstate, and it indicates the number of bytes read. vfscanf() now resembles vfwscanf() more closely. Minor functional improvements include working xlocale support in vfscanf(), setting the stream error indicator on encoding errors, and proper handling of shift-based encodings. (Actually, making shift-based encodings work with non-wide streams is hopeless, but the implementation now matches the broken specification.) Modified: head/lib/libc/stdio/fgetwc.c head/lib/libc/stdio/local.h head/lib/libc/stdio/vfscanf.c Modified: head/lib/libc/stdio/fgetwc.c ============================================================================== --- head/lib/libc/stdio/fgetwc.c Sun Apr 29 16:26:55 2012 (r234798) +++ head/lib/libc/stdio/fgetwc.c Sun Apr 29 16:28:39 2012 (r234799) @@ -59,6 +59,7 @@ fgetwc_l(FILE *fp, locale_t locale) return (r); } + wint_t fgetwc(FILE *fp) { @@ -66,40 +67,45 @@ fgetwc(FILE *fp) } /* - * Non-MT-safe version. + * Internal (non-MPSAFE) version of fgetwc(). This version takes an + * mbstate_t argument specifying the initial conversion state. For + * wide streams, this should always be fp->_mbstate. On return, *nread + * is set to the number of bytes read. */ -wint_t -__fgetwc(FILE *fp, locale_t locale) +wint_t +__fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale) { wchar_t wc; size_t nconv; struct xlocale_ctype *l = XLOCALE_CTYPE(locale); - if (fp->_r <= 0 && __srefill(fp)) + if (fp->_r <= 0 && __srefill(fp)) { + *nread = 0; return (WEOF); + } if (MB_CUR_MAX == 1) { /* Fast path for single-byte encodings. */ wc = *fp->_p++; fp->_r--; + *nread = 1; return (wc); } + *nread = 0; do { - nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, &fp->_mbstate); + nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs); if (nconv == (size_t)-1) break; else if (nconv == (size_t)-2) continue; else if (nconv == 0) { - /* - * Assume that the only valid representation of - * the null wide character is a single null byte. - */ fp->_p++; fp->_r--; + (*nread)++; return (L'\0'); } else { fp->_p += nconv; fp->_r -= nconv; + *nread += nconv; return (wc); } } while (__srefill(fp) == 0); Modified: head/lib/libc/stdio/local.h ============================================================================== --- head/lib/libc/stdio/local.h Sun Apr 29 16:26:55 2012 (r234798) +++ head/lib/libc/stdio/local.h Sun Apr 29 16:28:39 2012 (r234799) @@ -56,7 +56,7 @@ extern int _ftello(FILE *, fpos_t *); extern int _fseeko(FILE *, off_t, int, int); extern int __fflush(FILE *fp); extern void __fcloseall(void); -extern wint_t __fgetwc(FILE *, locale_t); +extern wint_t __fgetwc_mbs(FILE *, mbstate_t *, int *, locale_t); extern wint_t __fputwc(wchar_t, FILE *, locale_t); extern int __sflush(FILE *); extern FILE *__sfp(void); @@ -85,6 +85,13 @@ extern size_t __fread(void * __restrict FILE * __restrict fp); extern int __sdidinit; +static inline wint_t +__fgetwc(FILE *fp, locale_t locale) +{ + int nread; + + return (__fgetwc_mbs(fp, &fp->_mbstate, &nread, locale)); +} /* * Prepare the given FILE for writing, and return 0 iff it Modified: head/lib/libc/stdio/vfscanf.c ============================================================================== --- head/lib/libc/stdio/vfscanf.c Sun Apr 29 16:26:55 2012 (r234798) +++ head/lib/libc/stdio/vfscanf.c Sun Apr 29 16:28:39 2012 (r234799) @@ -127,9 +127,8 @@ static const mbstate_t initial_mbs; static __inline int convert_char(FILE *fp, char * __restrict p, int width) { - int n, nread; + int n; - nread = 0; if (p == SUPPRESS_PTR) { size_t sum = 0; for (;;) { @@ -149,59 +148,34 @@ convert_char(FILE *fp, char * __restrict break; } } - nread += sum; + return (sum); } else { size_t r = __fread(p, 1, width, fp); if (r == 0) return (-1); - nread += r; + return (r); } - return (nread); } static __inline int -convert_wchar(FILE *fp, wchar_t *wcp, int width) +convert_wchar(FILE *fp, wchar_t *wcp, int width, locale_t locale) { mbstate_t mbs; - size_t nconv; int n, nread; - char buf[MB_CUR_MAX]; + wint_t wi; - nread = 0; + mbs = initial_mbs; n = 0; - while (width != 0) { - if (n == MB_CUR_MAX) { - fp->_flags |= __SERR; - return (-1); - } - buf[n++] = *fp->_p; - fp->_p++; - fp->_r--; - mbs = initial_mbs; - nconv = mbrtowc(wcp, buf, n, &mbs); - if (nconv == (size_t)-1) { - fp->_flags |= __SERR; - return (-1); - } - if (nconv == 0 && wcp != SUPPRESS_PTR) - *wcp = L'\0'; - if (nconv != (size_t)-2) { - nread += n; - width--; - if (wcp != SUPPRESS_PTR) - wcp++; - n = 0; - } - if (fp->_r <= 0 && __srefill(fp)) { - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - break; - } + while (width-- != 0 && + (wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF) { + if (wcp != SUPPRESS_PTR) + *wcp++ = (wchar_t)wi; + n += nread; } - return (nread); + if (n == 0) + return (-1); + return (n); } static __inline int @@ -244,63 +218,34 @@ convert_ccl(FILE *fp, char * __restrict } static __inline int -convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab) +convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab, + locale_t locale) { mbstate_t mbs; - wchar_t twc; - int n, nchars, nconv; - char buf[MB_CUR_MAX]; + wint_t wi; + int n, nread; - if (wcp == SUPPRESS_PTR) - wcp = &twc; + mbs = initial_mbs; n = 0; - nchars = 0; - while (width != 0) { - if (n == MB_CUR_MAX) { - fp->_flags |= __SERR; - return (-1); - } - buf[n++] = *fp->_p; - fp->_p++; - fp->_r--; - mbs = initial_mbs; - nconv = mbrtowc(wcp, buf, n, &mbs); - if (nconv == (size_t)-1) { - fp->_flags |= __SERR; - return (-1); - } - if (nconv == 0) - *wcp = L'\0'; - if (nconv != (size_t)-2) { - if (wctob(*wcp) != EOF && !ccltab[wctob(*wcp)]) { - while (n != 0) { - n--; - __ungetc(buf[n], fp); - } - break; - } - width--; - if (wcp != &twc) - wcp++; - nchars++; - n = 0; - } - if (fp->_r <= 0 && __srefill(fp)) { - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - break; + if (wcp == SUPPRESS_PTR) { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && ccltab[wctob(wi)]) + n += nread; + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + } else { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && ccltab[wctob(wi)]) { + *wcp++ = (wchar_t)wi; + n += nread; } + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + if (n == 0) + return (0); + *wcp = 0; } - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - if (nchars == 0) - return (0); - *wcp = L'\0'; - return (nchars); + return (n); } static __inline int @@ -335,56 +280,31 @@ convert_string(FILE *fp, char * __restri } static __inline int -convert_wstring(FILE *fp, wchar_t *wcp, int width) +convert_wstring(FILE *fp, wchar_t *wcp, int width, locale_t locale) { mbstate_t mbs; - wchar_t twc; - int n, nconv, nread; - char buf[MB_CUR_MAX]; - - if (wcp == SUPPRESS_PTR) - wcp = &twc; - n = nread = 0; - while (!isspace(*fp->_p) && width != 0) { - if (n == MB_CUR_MAX) { - fp->_flags |= __SERR; - return (-1); - } - buf[n++] = *fp->_p; - fp->_p++; - fp->_r--; - mbs = initial_mbs; - nconv = mbrtowc(wcp, buf, n, &mbs); - if (nconv == (size_t)-1) { - fp->_flags |= __SERR; - return (-1); - } - if (nconv == 0) - *wcp = L'\0'; - if (nconv != (size_t)-2) { - if (iswspace(*wcp)) { - while (n != 0) { - n--; - __ungetc(buf[n], fp); - } - break; - } - nread += n; - width--; - if (wcp != &twc) - wcp++; - n = 0; - } - if (fp->_r <= 0 && __srefill(fp)) { - if (n != 0) { - fp->_flags |= __SERR; - return (-1); - } - break; - } + wint_t wi; + int n, nread; + + mbs = initial_mbs; + n = 0; + if (wcp == SUPPRESS_PTR) { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && !iswspace(wi)) + n += nread; + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + } else { + while ((wi = __fgetwc_mbs(fp, &mbs, &nread, locale)) != WEOF && + width-- != 0 && !iswspace(wi)) { + *wcp++ = (wchar_t)wi; + n += nread; + } + if (wi != WEOF) + __ungetwc(wi, fp, __get_locale()); + *wcp = '\0'; } - *wcp = L'\0'; - return (nread); + return (n); } /* @@ -766,7 +686,7 @@ literal: width = 1; if (flags & LONG) { nr = convert_wchar(fp, GETARG(wchar_t *), - width); + width, locale); } else { nr = convert_char(fp, GETARG(char *), width); } @@ -780,7 +700,7 @@ literal: width = (size_t)~0; /* `infinity' */ if (flags & LONG) { nr = convert_wccl(fp, GETARG(wchar_t *), width, - ccltab); + ccltab, locale); } else { nr = convert_ccl(fp, GETARG(char *), width, ccltab); @@ -799,7 +719,7 @@ literal: width = (size_t)~0; if (flags & LONG) { nr = convert_wstring(fp, GETARG(wchar_t *), - width); + width, locale); } else { nr = convert_string(fp, GETARG(char *), width); } From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 17:12:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 71095106566C; Sun, 29 Apr 2012 17:12:34 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 598F28FC08; Sun, 29 Apr 2012 17:12:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3THCYcK023920; Sun, 29 Apr 2012 17:12:34 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3THCY5C023914; Sun, 29 Apr 2012 17:12:34 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201204291712.q3THCY5C023914@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 29 Apr 2012 17:12:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234803 - in head/sys/dev/usb: . controller X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 17:12:34 -0000 Author: hselasky Date: Sun Apr 29 17:12:33 2012 New Revision: 234803 URL: http://svn.freebsd.org/changeset/base/234803 Log: Add support for Multi-TT mode of modern USB HUBs. This will give you more bandwidth for isochronous FULL speed applications connected through a High Speed HUB. This patch has been tested with XHCI and EHCI. MFC after: 1 week Modified: head/sys/dev/usb/controller/ehci.c head/sys/dev/usb/controller/xhci.c head/sys/dev/usb/usb_controller.h head/sys/dev/usb/usb_hub.c head/sys/dev/usb/usb_hub.h Modified: head/sys/dev/usb/controller/ehci.c ============================================================================== --- head/sys/dev/usb/controller/ehci.c Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/controller/ehci.c Sun Apr 29 17:12:33 2012 (r234803) @@ -2398,9 +2398,9 @@ ehci_device_isoc_fs_open(struct usb_xfer EHCI_SITD_SET_HUBA(xfer->xroot->udev->hs_hub_addr) | EHCI_SITD_SET_PORT(xfer->xroot->udev->hs_port_no); - if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) { + if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) sitd_portaddr |= EHCI_SITD_SET_DIR_IN; - } + sitd_portaddr = htohc32(sc, sitd_portaddr); /* initialize all TD's */ @@ -2436,9 +2436,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe { struct usb_page_search buf_res; ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); - struct usb_fs_isoc_schedule *fss_start; - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss; ehci_sitd_t *td; ehci_sitd_t *td_last = NULL; ehci_sitd_t **pp_last; @@ -2450,7 +2447,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe uint16_t tlen; uint8_t sa; uint8_t sb; - uint8_t error; #ifdef USB_DEBUG uint8_t once = 1; @@ -2495,9 +2491,8 @@ ehci_device_isoc_fs_enter(struct usb_xfe * pre-compute when the isochronous transfer will be finished: */ xfer->isoc_time_complete = - usbd_fs_isoc_schedule_isoc_time_expand - (xfer->xroot->udev, &fss_start, &fss_end, nframes) + buf_offset + - xfer->nframes; + usb_isoc_time_expand(&sc->sc_bus, nframes) + + buf_offset + xfer->nframes; /* get the real number of frames */ @@ -2520,19 +2515,14 @@ ehci_device_isoc_fs_enter(struct usb_xfe xfer->qh_pos = xfer->endpoint->isoc_next; - fss = fss_start + (xfer->qh_pos % USB_ISOC_TIME_MAX); - while (nframes--) { if (td == NULL) { panic("%s:%d: out of TD's\n", __FUNCTION__, __LINE__); } - if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) { + if (pp_last >= &sc->sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]) pp_last = &sc->sc_isoc_fs_p_last[0]; - } - if (fss >= fss_end) { - fss = fss_start; - } + /* reuse sitd_portaddr and sitd_back from last transfer */ if (*plen > xfer->max_frame_size) { @@ -2547,17 +2537,19 @@ ehci_device_isoc_fs_enter(struct usb_xfe #endif *plen = xfer->max_frame_size; } - /* - * We currently don't care if the ISOCHRONOUS schedule is - * full! - */ - error = usbd_fs_isoc_schedule_alloc(fss, &sa, *plen); - if (error) { + + /* allocate a slot */ + + sa = usbd_fs_isoc_schedule_alloc_slot(xfer, + xfer->isoc_time_complete - nframes - 1); + + if (sa == 255) { /* - * The FULL speed schedule is FULL! Set length - * to zero. + * Schedule is FULL, set length to zero: */ + *plen = 0; + sa = USB_FS_ISOC_UFRAME_MAX - 1; } if (*plen) { /* @@ -2637,7 +2629,6 @@ ehci_device_isoc_fs_enter(struct usb_xfe pp_last++; plen++; - fss++; td_last = td; td = td->obj_next; } Modified: head/sys/dev/usb/controller/xhci.c ============================================================================== --- head/sys/dev/usb/controller/xhci.c Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/controller/xhci.c Sun Apr 29 17:12:33 2012 (r234803) @@ -115,6 +115,7 @@ struct xhci_std_temp { uint8_t tbc; uint8_t tlbpc; uint8_t step_td; + uint8_t do_isoc_sync; }; static void xhci_do_poll(struct usb_bus *); @@ -1657,11 +1658,15 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(temp->trb_type) | - XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) | + XHCI_TRB_3_TYPE_SET(temp->trb_type) | + (temp->do_isoc_sync ? + XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8) : + XHCI_TRB_3_ISO_SIA_BIT) | XHCI_TRB_3_TBC_SET(temp->tbc) | XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + temp->do_isoc_sync = 0; + if (temp->direction == UE_DIR_IN) { dword |= XHCI_TRB_3_DIR_IN; @@ -1764,6 +1769,7 @@ xhci_setup_generic_chain(struct usb_xfer uint32_t y; uint8_t mult; + temp.do_isoc_sync = 0; temp.step_td = 0; temp.tbc = 0; temp.tlbpc = 0; @@ -1841,6 +1847,8 @@ xhci_setup_generic_chain(struct usb_xfer */ xfer->endpoint->isoc_next = XHCI_MFINDEX_GET(x + (3 * 8)); xfer->endpoint->is_synced = 1; + temp.do_isoc_sync = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); } @@ -1931,7 +1939,10 @@ xhci_setup_generic_chain(struct usb_xfer uint8_t tdpc; - /* isochronous transfers don't have short packet termination */ + /* + * Isochronous transfers don't have short + * packet termination: + */ temp.shortpkt = 1; @@ -2271,12 +2282,29 @@ xhci_configure_device(struct usb_device switch (udev->speed) { case USB_SPEED_LOW: temp |= XHCI_SCTX_0_SPEED_SET(2); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_HIGH: temp |= XHCI_SCTX_0_SPEED_SET(3); + if (sc->sc_hw.devs[index].nports != 0 && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { + DPRINTF("HUB supports MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; case USB_SPEED_FULL: temp |= XHCI_SCTX_0_SPEED_SET(1); + if (udev->parent_hs_hub != NULL && + udev->parent_hs_hub->ddesc.bDeviceProtocol == + UDPROTO_HSHUBMTT) { + DPRINTF("Device inherits MTT\n"); + temp |= XHCI_SCTX_0_MTT_SET(1); + } break; default: temp |= XHCI_SCTX_0_SPEED_SET(4); @@ -2287,15 +2315,8 @@ xhci_configure_device(struct usb_device (udev->speed == USB_SPEED_SUPER || udev->speed == USB_SPEED_HIGH); - if (is_hub) { + if (is_hub) temp |= XHCI_SCTX_0_HUB_SET(1); -#if 0 - if (udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) { - DPRINTF("HUB supports MTT\n"); - temp |= XHCI_SCTX_0_MTT_SET(1); - } -#endif - } xhci_ctx_set_le32(sc, &pinp->ctx_slot.dwSctx0, temp); @@ -2327,8 +2348,10 @@ xhci_configure_device(struct usb_device temp = XHCI_SCTX_2_IRQ_TARGET_SET(0); - if (is_hub) - temp |= XHCI_SCTX_2_TT_THINK_TIME_SET(sc->sc_hw.devs[index].tt); + if (is_hub) { + temp |= XHCI_SCTX_2_TT_THINK_TIME_SET( + sc->sc_hw.devs[index].tt); + } hubdev = udev->parent_hs_hub; Modified: head/sys/dev/usb/usb_controller.h ============================================================================== --- head/sys/dev/usb/usb_controller.h Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/usb_controller.h Sun Apr 29 17:12:33 2012 (r234803) @@ -231,7 +231,8 @@ void usb_bus_mem_flush_all(struct usb_bu uint8_t usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, usb_bus_mem_cb_t *cb); void usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb); uint16_t usb_isoc_time_expand(struct usb_bus *bus, uint16_t isoc_time_curr); -uint16_t usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, struct usb_fs_isoc_schedule **pp_start, struct usb_fs_isoc_schedule **pp_end, uint16_t isoc_time); -uint8_t usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, uint8_t *pstart, uint16_t len); +#if USB_HAVE_TT_SUPPORT +uint8_t usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time); +#endif #endif /* _USB_CONTROLLER_H_ */ Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/usb_hub.c Sun Apr 29 17:12:33 2012 (r234803) @@ -109,6 +109,7 @@ struct uhub_softc { #define UHUB_PROTO(sc) ((sc)->sc_udev->ddesc.bDeviceProtocol) #define UHUB_IS_HIGH_SPEED(sc) (UHUB_PROTO(sc) != UDPROTO_FSHUB) #define UHUB_IS_SINGLE_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBSTT) +#define UHUB_IS_MULTI_TT(sc) (UHUB_PROTO(sc) == UDPROTO_HSHUBMTT) #define UHUB_IS_SUPER_SPEED(sc) (UHUB_PROTO(sc) == UDPROTO_SSHUB) /* prototypes for type checking: */ @@ -948,6 +949,16 @@ uhub_attach(device_t dev) "bus powered HUB. HUB ignored\n"); goto error; } + + if (UHUB_IS_MULTI_TT(sc)) { + err = usbd_set_alt_interface_index(udev, 0, 1); + if (err) { + device_printf(dev, "MTT could not be enabled\n"); + goto error; + } + device_printf(dev, "MTT enabled\n"); + } + /* get HUB descriptor */ DPRINTFN(2, "Getting HUB descriptor\n"); @@ -1057,10 +1068,6 @@ uhub_attach(device_t dev) } udev->hub = hub; -#if USB_HAVE_TT_SUPPORT - /* init FULL-speed ISOCHRONOUS schedule */ - usbd_fs_isoc_schedule_init_all(hub->fs_isoc_schedule); -#endif /* initialize HUB structure */ hub->hubsoftc = sc; hub->explore = &uhub_explore; @@ -1656,42 +1663,6 @@ usb_hs_bandwidth_free(struct usb_xfer *x } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_sub - * - * This function initialises an USB FULL speed isochronous schedule - * entry. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -static void -usbd_fs_isoc_schedule_init_sub(struct usb_fs_isoc_schedule *fss) -{ - fss->total_bytes = (USB_FS_ISOC_UFRAME_MAX * - USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_bytes = (USB_FS_BYTES_PER_HS_UFRAME); - fss->frame_slot = 0; -} -#endif - -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_init_all - * - * This function will reset the complete USB FULL speed isochronous - * bandwidth schedule. - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -void -usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss) -{ - struct usb_fs_isoc_schedule *fss_end = fss + USB_ISOC_TIME_MAX; - - while (fss != fss_end) { - usbd_fs_isoc_schedule_init_sub(fss); - fss++; - } -} -#endif - -/*------------------------------------------------------------------------* * usb_isoc_time_expand * * This function will expand the time counter from 7-bit to 16-bit. @@ -1723,114 +1694,130 @@ usb_isoc_time_expand(struct usb_bus *bus } /*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_isoc_time_expand + * usbd_fs_isoc_schedule_alloc_slot * - * This function does multiple things. First of all it will expand the - * passed isochronous time, which is the return value. Then it will - * store where the current FULL speed isochronous schedule is - * positioned in time and where the end is. See "pp_start" and - * "pp_end" arguments. + * This function will allocate bandwidth for an isochronous FULL speed + * transaction in the FULL speed schedule. * * Returns: - * Expanded version of "isoc_time". - * - * NOTE: This function depends on being called regularly with - * intervals less than "USB_ISOC_TIME_MAX". + * <8: Success + * Else: Error *------------------------------------------------------------------------*/ #if USB_HAVE_TT_SUPPORT -uint16_t -usbd_fs_isoc_schedule_isoc_time_expand(struct usb_device *udev, - struct usb_fs_isoc_schedule **pp_start, - struct usb_fs_isoc_schedule **pp_end, - uint16_t isoc_time) +uint8_t +usbd_fs_isoc_schedule_alloc_slot(struct usb_xfer *isoc_xfer, uint16_t isoc_time) { - struct usb_fs_isoc_schedule *fss_end; - struct usb_fs_isoc_schedule *fss_a; - struct usb_fs_isoc_schedule *fss_b; - struct usb_hub *hs_hub; + struct usb_xfer *xfer; + struct usb_xfer *pipe_xfer; + struct usb_bus *bus; + usb_frlength_t len; + usb_frlength_t data_len; + uint16_t delta; + uint16_t slot; + uint8_t retval; - isoc_time = usb_isoc_time_expand(udev->bus, isoc_time); + data_len = 0; + slot = 0; - hs_hub = udev->parent_hs_hub->hub; + bus = isoc_xfer->xroot->bus; - if (hs_hub != NULL) { + TAILQ_FOREACH(xfer, &bus->intr_q.head, wait_entry) { - fss_a = hs_hub->fs_isoc_schedule + - (hs_hub->isoc_last_time % USB_ISOC_TIME_MAX); + /* skip self, if any */ - hs_hub->isoc_last_time = isoc_time; + if (xfer == isoc_xfer) + continue; - fss_b = hs_hub->fs_isoc_schedule + - (isoc_time % USB_ISOC_TIME_MAX); + /* check if this USB transfer is going through the same TT */ - fss_end = hs_hub->fs_isoc_schedule + USB_ISOC_TIME_MAX; + if (xfer->xroot->udev->parent_hs_hub != + isoc_xfer->xroot->udev->parent_hs_hub) { + continue; + } + if ((isoc_xfer->xroot->udev->parent_hs_hub-> + ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) && + (xfer->xroot->udev->hs_port_no != + isoc_xfer->xroot->udev->hs_port_no)) { + continue; + } + if (xfer->endpoint->methods != isoc_xfer->endpoint->methods) + continue; + + /* check if isoc_time is part of this transfer */ + + delta = xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= xfer->nframes) { + delta = xfer->nframes - delta; + + len = xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; + } + + /* check double buffered transfers */ - *pp_start = hs_hub->fs_isoc_schedule; - *pp_end = fss_end; + TAILQ_FOREACH(pipe_xfer, &xfer->endpoint->endpoint_q.head, + wait_entry) { - while (fss_a != fss_b) { - if (fss_a == fss_end) { - fss_a = hs_hub->fs_isoc_schedule; + /* skip self, if any */ + + if (pipe_xfer == isoc_xfer) continue; + + /* check if isoc_time is part of this transfer */ + + delta = pipe_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= pipe_xfer->nframes) { + delta = pipe_xfer->nframes - delta; + + len = pipe_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - usbd_fs_isoc_schedule_init_sub(fss_a); - fss_a++; } + } - } else { - - *pp_start = NULL; - *pp_end = NULL; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; } - return (isoc_time); -} -#endif -/*------------------------------------------------------------------------* - * usbd_fs_isoc_schedule_alloc - * - * This function will allocate bandwidth for an isochronous FULL speed - * transaction in the FULL speed schedule. The microframe slot where - * the transaction should be started is stored in the byte pointed to - * by "pstart". The "len" argument specifies the length of the - * transaction in bytes. - * - * Returns: - * 0: Success - * Else: Error - *------------------------------------------------------------------------*/ -#if USB_HAVE_TT_SUPPORT -uint8_t -usbd_fs_isoc_schedule_alloc(struct usb_fs_isoc_schedule *fss, - uint8_t *pstart, uint16_t len) -{ - uint8_t slot = fss->frame_slot; + /* check for overflow */ - /* Compute overhead and bit-stuffing */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); - len += 8; + retval = slot; - len *= 7; - len /= 6; + delta = isoc_xfer->isoc_time_complete - isoc_time; + if (delta > 0 && delta <= isoc_xfer->nframes) { + delta = isoc_xfer->nframes - delta; - if (len > fss->total_bytes) { - *pstart = 0; /* set some dummy value */ - return (1); /* error */ + len = isoc_xfer->frlengths[delta]; + len += 8; + len *= 7; + len /= 6; + + data_len += len; } - if (len > 0) { - fss->total_bytes -= len; + while (data_len >= USB_FS_BYTES_PER_HS_UFRAME) { + data_len -= USB_FS_BYTES_PER_HS_UFRAME; + slot++; + } - while (len >= fss->frame_bytes) { - len -= fss->frame_bytes; - fss->frame_bytes = USB_FS_BYTES_PER_HS_UFRAME; - fss->frame_slot++; - } + /* check for overflow */ - fss->frame_bytes -= len; - } - *pstart = slot; - return (0); /* success */ + if (slot >= USB_FS_ISOC_UFRAME_MAX) + return (255); + + return (retval); } #endif Modified: head/sys/dev/usb/usb_hub.h ============================================================================== --- head/sys/dev/usb/usb_hub.h Sun Apr 29 16:35:55 2012 (r234802) +++ head/sys/dev/usb/usb_hub.h Sun Apr 29 17:12:33 2012 (r234803) @@ -38,22 +38,9 @@ struct usb_port { }; /* - * The following structure defines how many bytes are - * left in an 1ms USB time slot. - */ -struct usb_fs_isoc_schedule { - uint16_t total_bytes; - uint8_t frame_bytes; - uint8_t frame_slot; -}; - -/* * The following structure defines an USB HUB. */ struct usb_hub { -#if USB_HAVE_TT_SUPPORT - struct usb_fs_isoc_schedule fs_isoc_schedule[USB_ISOC_TIME_MAX]; -#endif struct usb_device *hubudev; /* the HUB device */ usb_error_t (*explore) (struct usb_device *hub); void *hubsoftc; @@ -68,7 +55,6 @@ struct usb_hub { void usb_hs_bandwidth_alloc(struct usb_xfer *xfer); void usb_hs_bandwidth_free(struct usb_xfer *xfer); -void usbd_fs_isoc_schedule_init_all(struct usb_fs_isoc_schedule *fss); void usb_bus_port_set_device(struct usb_bus *bus, struct usb_port *up, struct usb_device *udev, uint8_t device_index); struct usb_device *usb_bus_port_get_device(struct usb_bus *bus, From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 19:40:51 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 89B28106564A; Sun, 29 Apr 2012 19:40:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 756FE8FC16; Sun, 29 Apr 2012 19:40:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TJep4g029436; Sun, 29 Apr 2012 19:40:51 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TJepJs029434; Sun, 29 Apr 2012 19:40:51 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201204291940.q3TJepJs029434@svn.freebsd.org> From: Alexander Motin Date: Sun, 29 Apr 2012 19:40:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234816 - head/sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 19:40:51 -0000 Author: mav Date: Sun Apr 29 19:40:50 2012 New Revision: 234816 URL: http://svn.freebsd.org/changeset/base/234816 Log: s/gmirror/graid/ Modified: head/sys/geom/raid/g_raid.c Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Sun Apr 29 18:55:52 2012 (r234815) +++ head/sys/geom/raid/g_raid.c Sun Apr 29 19:40:50 2012 (r234816) @@ -1823,8 +1823,8 @@ g_raid_create_node(struct g_class *mp, sc->sc_flags = 0; TAILQ_INIT(&sc->sc_volumes); TAILQ_INIT(&sc->sc_disks); - sx_init(&sc->sc_lock, "gmirror:lock"); - mtx_init(&sc->sc_queue_mtx, "gmirror:queue", NULL, MTX_DEF); + sx_init(&sc->sc_lock, "graid:lock"); + mtx_init(&sc->sc_queue_mtx, "graid:queue", NULL, MTX_DEF); TAILQ_INIT(&sc->sc_events); bioq_init(&sc->sc_queue); gp->softc = sc; From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 22:19:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30DB1106564A; Sun, 29 Apr 2012 22:19:59 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C3998FC1A; Sun, 29 Apr 2012 22:19:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TMJwOu035081; Sun, 29 Apr 2012 22:19:58 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMJwkw035078; Sun, 29 Apr 2012 22:19:58 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292219.q3TMJwkw035078@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:19:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234819 - head/lib/libc/gmon X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:19:59 -0000 Author: eadler Date: Sun Apr 29 22:19:58 2012 New Revision: 234819 URL: http://svn.freebsd.org/changeset/base/234819 Log: Allow users of gprof to get per run output files (using the pid) PR: bin/99800 Submitted by: Peter Jeremy Reviewed by: jilles (code) Reviewed by: dwhite (doc) Approved by: cperciva MFC after: 1 week Modified: head/lib/libc/gmon/gmon.c head/lib/libc/gmon/moncontrol.3 Modified: head/lib/libc/gmon/gmon.c ============================================================================== --- head/lib/libc/gmon/gmon.c Sun Apr 29 22:01:23 2012 (r234818) +++ head/lib/libc/gmon/gmon.c Sun Apr 29 22:19:58 2012 (r234819) @@ -157,7 +157,12 @@ _mcleanup(void) } moncontrol(0); - snprintf(outname, sizeof(outname), "%s.gmon", _getprogname()); + if (getenv("PROFIL_USE_PID")) + snprintf(outname, sizeof(outname), "%s.%d.gmon", + _getprogname(), getpid()); + else + snprintf(outname, sizeof(outname), "%s.gmon", _getprogname()); + fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (fd < 0) { _warn("_mcleanup: %s", outname); Modified: head/lib/libc/gmon/moncontrol.3 ============================================================================== --- head/lib/libc/gmon/moncontrol.3 Sun Apr 29 22:01:23 2012 (r234818) +++ head/lib/libc/gmon/moncontrol.3 Sun Apr 29 22:19:58 2012 (r234819) @@ -98,6 +98,12 @@ however, all functions in that address r have their execution time measured. Profiling begins on return from .Fn monstartup . +.Sh ENVIRONMENT +The following environment variables affect the execution of +.Nm : +.Bl -tag -width ".Ev PROFIL_USE_PID" +.It PROFIL_USE_PID +If set, the pid of the process is inserted into the filename. .Sh FILES .Bl -tag -width progname.gmon -compact .It Pa progname.gmon From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 22:23:01 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BBC2106566C; Sun, 29 Apr 2012 22:23:01 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EABE68FC08; Sun, 29 Apr 2012 22:23:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TMN00T035220; Sun, 29 Apr 2012 22:23:00 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMN0BJ035218; Sun, 29 Apr 2012 22:23:00 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292223.q3TMN0BJ035218@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:23:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234820 - head/lib/libc/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:23:01 -0000 Author: eadler Date: Sun Apr 29 22:23:00 2012 New Revision: 234820 URL: http://svn.freebsd.org/changeset/base/234820 Log: pread(2) might fail with EBUSY, so document it PR: docs/167201 Submitted by: Kurt Jaeger Approved by: cperciva MFC after: 3 days Modified: head/lib/libc/sys/read.2 Modified: head/lib/libc/sys/read.2 ============================================================================== --- head/lib/libc/sys/read.2 Sun Apr 29 22:19:58 2012 (r234819) +++ head/lib/libc/sys/read.2 Sun Apr 29 22:23:00 2012 (r234820) @@ -164,6 +164,8 @@ argument points outside the allocated address space. .It Bq Er EIO An I/O error occurred while reading from the file system. +.It Bq Er EBUSY +Failed to read from a file, e.g. /proc//regs while is not stopped .It Bq Er EINTR A read from a slow device (i.e.\& one that might block for an arbitrary amount of time) From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 22:28:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0DBA01065670; Sun, 29 Apr 2012 22:28:16 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ECAF58FC0A; Sun, 29 Apr 2012 22:28:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TMSFSb035426; Sun, 29 Apr 2012 22:28:15 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMSFrC035424; Sun, 29 Apr 2012 22:28:15 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292228.q3TMSFrC035424@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:28:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234821 - head/sys/cam/scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:28:16 -0000 Author: eadler Date: Sun Apr 29 22:28:15 2012 New Revision: 234821 URL: http://svn.freebsd.org/changeset/base/234821 Log: Add support for: Olympus FE-210 camera LG UP3S MP3 player Laser MP3-2GA13 MP3 PR: usb/119201 Submitted by: Peter Jeremy Approved by: cperciva MFC after: 1 week Modified: head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Sun Apr 29 22:23:00 2012 (r234820) +++ head/sys/cam/scsi/scsi_da.c Sun Apr 29 22:28:15 2012 (r234821) @@ -811,6 +811,27 @@ static struct da_quirk_entry da_quirk_ta { T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "???PVT*", "*" }, /*quirks*/DA_Q_4K }, + { + /* + * Olympus FE-210 camera + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "OLYMPUS", "FE210*", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, + { + /* + * LG UP3S MP3 player + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "LG", "UP3S", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, + { + /* + * Laser MP3-2GA13 MP3 player + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "USB 2.0", "(HS) Flash Disk", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, }; static disk_strategy_t dastrategy; From owner-svn-src-head@FreeBSD.ORG Sun Apr 29 22:29:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A11B7106564A; Sun, 29 Apr 2012 22:29:48 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C4708FC15; Sun, 29 Apr 2012 22:29:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3TMTmDs035551; Sun, 29 Apr 2012 22:29:48 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3TMTm9p035549; Sun, 29 Apr 2012 22:29:48 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201204292229.q3TMTm9p035549@svn.freebsd.org> From: Eitan Adler Date: Sun, 29 Apr 2012 22:29:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234823 - head/share/skel X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2012 22:29:48 -0000 Author: eadler Date: Sun Apr 29 22:29:48 2012 New Revision: 234823 URL: http://svn.freebsd.org/changeset/base/234823 Log: Copy recent changes from etc/root/dot.cshrc that make the defaults more user friendly Approved by: cperciva MFC after: 3 days Modified: head/share/skel/dot.cshrc Modified: head/share/skel/dot.cshrc ============================================================================== --- head/share/skel/dot.cshrc Sun Apr 29 22:29:28 2012 (r234822) +++ head/share/skel/dot.cshrc Sun Apr 29 22:29:48 2012 (r234823) @@ -3,13 +3,14 @@ # .cshrc - csh resource script, read at beginning of execution by each shell # # see also csh(1), environ(7). +# more examples available at /usr/share/examples/csh/ # alias h history 25 alias j jobs -l -alias la ls -a +alias la ls -aF alias lf ls -FA -alias ll ls -lA +alias ll ls -lAF # A righteous umask umask 22 @@ -17,18 +18,29 @@ umask 22 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi -setenv PAGER more +setenv PAGER less setenv BLOCKSIZE K if ($?prompt) then # An interactive shell -- set some stuff up + if ($uid == 0) then + set user = root + endif + set prompt = "%n@%m:%/ %# " + set promptchars = "%#" + set filec - set history = 100 - set savehist = 100 + set history = 1000 + set savehist = (1000 merge) + set autolist = ambiguous + # Use history to aid expansion + set autoexpand + set autorehash set mail = (/var/mail/$USER) if ( $?tcsh ) then bindkey "^W" backward-delete-word bindkey -k up history-search-backward bindkey -k down history-search-forward endif + endif From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 00:54:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EECBF106566C; Mon, 30 Apr 2012 00:54:10 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DAC0D8FC0C; Mon, 30 Apr 2012 00:54:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U0sAAs040518; Mon, 30 Apr 2012 00:54:10 GMT (envelope-from gad@svn.freebsd.org) Received: (from gad@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U0sAND040516; Mon, 30 Apr 2012 00:54:10 GMT (envelope-from gad@svn.freebsd.org) Message-Id: <201204300054.q3U0sAND040516@svn.freebsd.org> From: Garance A Drosehn Date: Mon, 30 Apr 2012 00:54:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234824 - head/usr.sbin/lpr/lpc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 00:54:11 -0000 Author: gad Date: Mon Apr 30 00:54:10 2012 New Revision: 234824 URL: http://svn.freebsd.org/changeset/base/234824 Log: Catch the user-error when no queue name was specified on an lpc-command which supports '-msg' (e.g.: setstatus). Print out a helpful error message instead hitting a seg-fault. MFC after: 3 weeks Modified: head/usr.sbin/lpr/lpc/cmds.c Modified: head/usr.sbin/lpr/lpc/cmds.c ============================================================================== --- head/usr.sbin/lpr/lpc/cmds.c Sun Apr 29 22:29:48 2012 (r234823) +++ head/usr.sbin/lpr/lpc/cmds.c Mon Apr 30 00:54:10 2012 (r234824) @@ -163,6 +163,14 @@ generic(void (*specificrtn)(struct print break; } } + if (argc < 1) { + printf("error: No printer name(s) specified before" + " '-msg'.\n"); + printf("usage: %s {all | printer ...}", + generic_cmdname); + printf(" [-msg ...]\n"); + return; + } } /* call initialization routine, if there is one for this cmd */ From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 01:08:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1498E106566B; Mon, 30 Apr 2012 01:08:19 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA69E8FC08; Mon, 30 Apr 2012 01:08:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U18Ifc041046; Mon, 30 Apr 2012 01:08:18 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U18IKb041043; Mon, 30 Apr 2012 01:08:18 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201204300108.q3U18IKb041043@svn.freebsd.org> From: David Schultz Date: Mon, 30 Apr 2012 01:08:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234825 - head/lib/libc/stdio X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 01:08:19 -0000 Author: das Date: Mon Apr 30 01:08:18 2012 New Revision: 234825 URL: http://svn.freebsd.org/changeset/base/234825 Log: Fix a bug in *wscanf's handling of non-wide %s, %c, and %[ conversions. Both the specification and the documentation say the width is interpreted as the max number of wide characters to read, but the implementation was interpreting it as the number of bytes to convert. (See also r105317.) This change has security implications for any applications that depend on the buggy behavior, but the impact in practice is probably nil. Any such application would already be buggy on other platforms that get the semantics right. Also, these conversions are rarely used; %ls, %lc, and %l[ are more appropriate. Modified: head/lib/libc/stdio/vfwscanf.c Modified: head/lib/libc/stdio/vfwscanf.c ============================================================================== --- head/lib/libc/stdio/vfwscanf.c Mon Apr 30 00:54:10 2012 (r234824) +++ head/lib/libc/stdio/vfwscanf.c Mon Apr 30 01:08:18 2012 (r234825) @@ -144,29 +144,16 @@ convert_char(FILE *fp, char * __restrict size_t nconv; wint_t wi; int n; - char mbbuf[MB_LEN_MAX]; n = 0; mbs = initial_mbs; - while (width != 0 && (wi = __fgetwc(fp, locale)) != WEOF) { - if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) { + while (width-- != 0 && (wi = __fgetwc(fp, locale)) != WEOF) { + if (mbp != SUPPRESS_PTR) { nconv = wcrtomb(mbp, wi, &mbs); if (nconv == (size_t)-1) return (-1); - } else { - nconv = wcrtomb(mbbuf, wi, &mbs); - if (nconv == (size_t)-1) - return (-1); - if (nconv > width) { - __ungetwc(wi, fp, locale); - break; - } - if (mbp != SUPPRESS_PTR) - memcpy(mbp, mbbuf, nconv); - } - if (mbp != SUPPRESS_PTR) mbp += nconv; - width -= nconv; + } n++; } if (n == 0) @@ -199,28 +186,17 @@ convert_ccl(FILE *fp, char * __restrict size_t nconv; wint_t wi; int n; - char mbbuf[MB_LEN_MAX]; n = 0; mbs = initial_mbs; while ((wi = __fgetwc(fp, locale)) != WEOF && - width != 0 && inccl(ccl, wi)) { - if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) { + width-- != 0 && inccl(ccl, wi)) { + if (mbp != SUPPRESS_PTR) { nconv = wcrtomb(mbp, wi, &mbs); if (nconv == (size_t)-1) return (-1); - } else { - nconv = wcrtomb(mbbuf, wi, &mbs); - if (nconv == (size_t)-1) - return (-1); - if (nconv > width) - break; - if (mbp != SUPPRESS_PTR) - memcpy(mbp, mbbuf, nconv); - } - if (mbp != SUPPRESS_PTR) mbp += nconv; - width -= nconv; + } n++; } if (wi != WEOF) @@ -267,28 +243,17 @@ convert_string(FILE *fp, char * __restri size_t nconv; wint_t wi; int nread; - char mbbuf[MB_LEN_MAX]; mbs = initial_mbs; nread = 0; - while ((wi = __fgetwc(fp, locale)) != WEOF && width != 0 && + while ((wi = __fgetwc(fp, locale)) != WEOF && width-- != 0 && !iswspace(wi)) { - if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) { + if (mbp != SUPPRESS_PTR) { nconv = wcrtomb(mbp, wi, &mbs); if (nconv == (size_t)-1) return (-1); - } else { - nconv = wcrtomb(mbbuf, wi, &mbs); - if (nconv == (size_t)-1) - return (-1); - if (nconv > width) - break; - if (mbp != SUPPRESS_PTR) - memcpy(mbp, mbbuf, nconv); - } - if (mbp != SUPPRESS_PTR) mbp += nconv; - width -= nconv; + } nread++; } if (wi != WEOF) From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 01:10:14 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E0AE1065670; Mon, 30 Apr 2012 01:10:14 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0945A8FC08; Mon, 30 Apr 2012 01:10:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U1ADo0041143; Mon, 30 Apr 2012 01:10:13 GMT (envelope-from gad@svn.freebsd.org) Received: (from gad@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U1ADTT041141; Mon, 30 Apr 2012 01:10:13 GMT (envelope-from gad@svn.freebsd.org) Message-Id: <201204300110.q3U1ADTT041141@svn.freebsd.org> From: Garance A Drosehn Date: Mon, 30 Apr 2012 01:10:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234826 - head/usr.sbin/lpr/lpc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 01:10:14 -0000 Author: gad Date: Mon Apr 30 01:10:13 2012 New Revision: 234826 URL: http://svn.freebsd.org/changeset/base/234826 Log: Print out a warning message if a `lpc setstatus' is done when the queue is not 'lpc stop'-ed. In that situation `lpq' will not display the status message to the user, and the operator may think the queue is already stopped when it is not. MFC after: 3 weeks Modified: head/usr.sbin/lpr/lpc/cmds.c Modified: head/usr.sbin/lpr/lpc/cmds.c ============================================================================== --- head/usr.sbin/lpr/lpc/cmds.c Mon Apr 30 01:08:18 2012 (r234825) +++ head/usr.sbin/lpr/lpc/cmds.c Mon Apr 30 01:10:13 2012 (r234826) @@ -1009,12 +1009,30 @@ setstatus_gi(int argc __unused, char *ar void setstatus_q(struct printer *pp) { + struct stat stbuf; + int not_shown; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); upstat(pp, generic_msg, 1); + + /* + * Warn the user if 'lpq' will not display this new status-message. + * Note that if lock file does not exist, then the queue is enabled + * for both queuing and printing. + */ + not_shown = 1; + if (stat(lf, &stbuf) >= 0) { + if (stbuf.st_mode & LFM_PRINT_DIS) + not_shown = 0; + } + if (not_shown) { + printf("\tnote: This queue currently has printing enabled,\n"); + printf("\t so this -msg will only be shown by 'lpq' if\n"); + printf("\t a job is actively printing on it.\n"); + } } /* From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 07:32:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9B6FB106566B; Mon, 30 Apr 2012 07:32:40 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 861A68FC08; Mon, 30 Apr 2012 07:32:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U7WeZr054578; Mon, 30 Apr 2012 07:32:40 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U7Wem5054576; Mon, 30 Apr 2012 07:32:40 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201204300732.q3U7Wem5054576@svn.freebsd.org> From: Robert Watson Date: Mon, 30 Apr 2012 07:32:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234829 - head/lib/libc/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 07:32:40 -0000 Author: rwatson Date: Mon Apr 30 07:32:39 2012 New Revision: 234829 URL: http://svn.freebsd.org/changeset/base/234829 Log: The returned file descriptor from pdfork(2) is via fdp, not pidp. Submitted by: Norman Hardy MFC after: 3 days Modified: head/lib/libc/sys/pdfork.2 Modified: head/lib/libc/sys/pdfork.2 ============================================================================== --- head/lib/libc/sys/pdfork.2 Mon Apr 30 06:54:44 2012 (r234828) +++ head/lib/libc/sys/pdfork.2 Mon Apr 30 07:32:39 2012 (r234829) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2009-2010 Robert N. M. Watson +.\" Copyright (c) 2009-2010, 2012 Robert N. M. Watson .\" All rights reserved. .\" .\" This software was developed at the University of Cambridge Computer @@ -57,7 +57,7 @@ a variant of .Xr fork 2 , which, if successful, returns a process descriptor in the integer pointed to by -.Fa pidp . +.Fa fdp . Processes created via .Fn pdfork will not cause From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 08:00:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B795E1065670; Mon, 30 Apr 2012 08:00:52 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A3A328FC15; Mon, 30 Apr 2012 08:00:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U80qFm055531; Mon, 30 Apr 2012 08:00:52 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U80qvd055529; Mon, 30 Apr 2012 08:00:52 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201204300800.q3U80qvd055529@svn.freebsd.org> From: Robert Watson Date: Mon, 30 Apr 2012 08:00:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234830 - head/lib/libc/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:00:52 -0000 Author: rwatson Date: Mon Apr 30 08:00:52 2012 New Revision: 234830 URL: http://svn.freebsd.org/changeset/base/234830 Log: fix a further typo in the pdfork(2) man page. Submitted by: Norman Hardy MFC after: 3 days Modified: head/lib/libc/sys/pdfork.2 Modified: head/lib/libc/sys/pdfork.2 ============================================================================== --- head/lib/libc/sys/pdfork.2 Mon Apr 30 07:32:39 2012 (r234829) +++ head/lib/libc/sys/pdfork.2 Mon Apr 30 08:00:52 2012 (r234830) @@ -76,7 +76,7 @@ This option is not permitted in Capsicum .El .Pp .Fn pdgetpid -queries the process ID (PID) if the process descriptor +queries the process ID (PID) in the process descriptor .Fa fd . .Pp .Fn pdkill From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 08:44:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17DCA106566B; Mon, 30 Apr 2012 08:44:11 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 035488FC0A; Mon, 30 Apr 2012 08:44:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U8iAlh056906; Mon, 30 Apr 2012 08:44:10 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U8iAEj056904; Mon, 30 Apr 2012 08:44:10 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201204300844.q3U8iAEj056904@svn.freebsd.org> From: Navdeep Parhar Date: Mon, 30 Apr 2012 08:44:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234831 - head/sys/dev/cxgbe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:44:11 -0000 Author: np Date: Mon Apr 30 08:44:10 2012 New Revision: 234831 URL: http://svn.freebsd.org/changeset/base/234831 Log: Make sure that the firmware version is available in dev.t4nex.X.firmware_version even if the driver fails to attach properly. At least it'll be easy to tell what we're dealing with. MFC after: 1 week Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Mon Apr 30 08:00:52 2012 (r234830) +++ head/sys/dev/cxgbe/t4_main.c Mon Apr 30 08:44:10 2012 (r234831) @@ -1449,6 +1449,11 @@ prep_firmware(struct adapter *sc) /* Check firmware version and install a different one if necessary */ rc = t4_check_fw_version(sc); + snprintf(sc->fw_version, sizeof(sc->fw_version), "%u.%u.%u.%u", + G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), + G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); if (rc != 0) { uint32_t v = 0; @@ -1505,6 +1510,12 @@ prep_firmware(struct adapter *sc) } else { /* refresh */ (void) t4_check_fw_version(sc); + snprintf(sc->fw_version, + sizeof(sc->fw_version), "%u.%u.%u.%u", + G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), + G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), + G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); } } } @@ -1548,11 +1559,6 @@ prep_firmware(struct adapter *sc) goto done; /* error message displayed already */ } - snprintf(sc->fw_version, sizeof(sc->fw_version), "%u.%u.%u.%u", - G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers), - G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers), - G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers), - G_FW_HDR_FW_VER_BUILD(sc->params.fw_vers)); sc->flags |= FW_OK; done: From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 08:44:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CFF810657C1; Mon, 30 Apr 2012 08:44:22 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 878D18FC15; Mon, 30 Apr 2012 08:44:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U8iMED056948; Mon, 30 Apr 2012 08:44:22 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U8iMQt056945; Mon, 30 Apr 2012 08:44:22 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201204300844.q3U8iMQt056945@svn.freebsd.org> From: Michael Tuexen Date: Mon, 30 Apr 2012 08:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234832 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:44:22 -0000 Author: tuexen Date: Mon Apr 30 08:44:21 2012 New Revision: 234832 URL: http://svn.freebsd.org/changeset/base/234832 Log: Add support for missing gauth_number_of_chunks field. This Bug was found by Irene Ruengeler. MFC after: 1 week Modified: head/sys/netinet/sctp_uio.h head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Mon Apr 30 08:44:10 2012 (r234831) +++ head/sys/netinet/sctp_uio.h Mon Apr 30 08:44:21 2012 (r234832) @@ -660,6 +660,7 @@ struct sctp_authkeyid { /* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */ struct sctp_authchunks { sctp_assoc_t gauth_assoc_id; + uint32_t gauth_number_of_chunks; uint8_t gauth_chunks[]; }; Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Mon Apr 30 08:44:10 2012 (r234831) +++ head/sys/netinet/sctp_usrreq.c Mon Apr 30 08:44:21 2012 (r234832) @@ -2879,6 +2879,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); + sac->gauth_number_of_chunks = (uint32_t) size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_TCB_UNLOCK(stcb); @@ -2897,6 +2898,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); + sac->gauth_number_of_chunks = (uint32_t) size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_INP_RUNLOCK(inp); @@ -2927,6 +2929,7 @@ flags_out: } else { /* copy in the chunks */ (void)sctp_serialize_auth_chunks(chklist, sac->gauth_chunks); + sac->gauth_number_of_chunks = (uint32_t) size; *optsize = sizeof(struct sctp_authchunks) + size; } SCTP_TCB_UNLOCK(stcb); From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 08:55:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78EBA106564A; Mon, 30 Apr 2012 08:55:23 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mail.ipfw.ru (unknown [IPv6:2a01:4f8:120:6141::2]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC768FC17; Mon, 30 Apr 2012 08:55:23 +0000 (UTC) Received: from v6.mpls.in ([2a02:978:2::5] helo=ws.su29.net) by mail.ipfw.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1SOmOH-0001ME-QR; Mon, 30 Apr 2012 12:55:29 +0400 Message-ID: <4F9E531B.6020203@FreeBSD.org> Date: Mon, 30 Apr 2012 12:53:47 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120121 Thunderbird/9.0 MIME-Version: 1.0 To: Adrian Chadd References: <201204060653.q366rwLa096182@svn.freebsd.org> <4F7E9413.20602@FreeBSD.org> <4F8BBD4E.1040106@FreeBSD.org> <4F91240C.3050703@ipfw.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, freebsd-net@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r233937 - in head/sys: kern net security/mac X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 08:55:23 -0000 On 28.04.2012 00:42, Adrian Chadd wrote: > Hi Alex, Hello! > > I don't want to be demanding, but would you please consider committing > your fixes? I've asked glebius@ for the review for a while ago, but it seems it is a bit staled.. > > And if you could, would you please do it as a set of commits, one per > 'thing', rather than one big monolithic commit that does half a dozen > different things? That way if there are any further regressions, > I/others could test things out. Ok, I'll try to commit fixes today. > > This is breaking bpf for a few people - ladv causes a crash, wifi also > causes a crash. > > Thanks! > > > Adrian > From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 09:46:06 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB684106564A; Mon, 30 Apr 2012 09:46:06 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C6338FC08; Mon, 30 Apr 2012 09:46:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3U9k61C058805; Mon, 30 Apr 2012 09:46:06 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3U9k62T058801; Mon, 30 Apr 2012 09:46:06 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201204300946.q3U9k62T058801@svn.freebsd.org> From: Navdeep Parhar Date: Mon, 30 Apr 2012 09:46:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234833 - in head: share/man/man4 sys/dev/cxgbe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 09:46:06 -0000 Author: np Date: Mon Apr 30 09:46:05 2012 New Revision: 234833 URL: http://svn.freebsd.org/changeset/base/234833 Log: Change the default to not use packet counters to generate rx interrupts. Rely solely on the timer based mechanism. Update man page to reflect this change. MFC after: 1 week Modified: head/share/man/man4/cxgbe.4 head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/t4_sge.c Modified: head/share/man/man4/cxgbe.4 ============================================================================== --- head/share/man/man4/cxgbe.4 Mon Apr 30 08:44:21 2012 (r234832) +++ head/share/man/man4/cxgbe.4 Mon Apr 30 09:46:05 2012 (r234833) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2011, Chelsio Inc +.\" Copyright (c) 2011-2012, Chelsio Inc .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -145,10 +145,9 @@ dev.cxgbe.X.holdoff_tmr_idx sysctl. The packet-count index value to use to delay interrupts. The packet-count list has the values 1, 8, 16, and 32 by default and the index selects a value from this list. -The default value is 2 for both 10Gb and 1Gb ports, which means 16 -packets (or the holdoff timer going off) before an interrupt is -generated. --1 disables packet counting. +The default value is -1 for both 10Gb and 1Gb ports, which means packet +counting is disabled and interrupts are generated based solely on the +holdoff timer value. Different cxgbe interfaces can be assigned different values via the dev.cxgbe.X.holdoff_pktc_idx sysctl. This sysctl works only when the interface has never been marked up (as done by Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Mon Apr 30 08:44:21 2012 (r234832) +++ head/sys/dev/cxgbe/t4_main.c Mon Apr 30 09:46:05 2012 (r234833) @@ -174,7 +174,7 @@ TUNABLE_INT("hw.cxgbe.nofldrxq1g", &t4_n static int t4_tmr_idx_10g = TMR_IDX_10G; TUNABLE_INT("hw.cxgbe.holdoff_timer_idx_10G", &t4_tmr_idx_10g); -#define PKTC_IDX_10G 2 +#define PKTC_IDX_10G (-1) static int t4_pktc_idx_10g = PKTC_IDX_10G; TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_10G", &t4_pktc_idx_10g); @@ -182,7 +182,7 @@ TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_1 static int t4_tmr_idx_1g = TMR_IDX_1G; TUNABLE_INT("hw.cxgbe.holdoff_timer_idx_1G", &t4_tmr_idx_1g); -#define PKTC_IDX_1G 2 +#define PKTC_IDX_1G (-1) static int t4_pktc_idx_1g = PKTC_IDX_1G; TUNABLE_INT("hw.cxgbe.holdoff_pktc_idx_1G", &t4_pktc_idx_1g); Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Mon Apr 30 08:44:21 2012 (r234832) +++ head/sys/dev/cxgbe/t4_sge.c Mon Apr 30 09:46:05 2012 (r234833) @@ -1420,9 +1420,12 @@ init_iq(struct sge_iq *iq, struct adapte iq->flags = 0; iq->adapter = sc; - iq->intr_params = V_QINTR_TIMER_IDX(tmr_idx) | - V_QINTR_CNT_EN(pktc_idx >= 0); - iq->intr_pktc_idx = pktc_idx; + iq->intr_params = V_QINTR_TIMER_IDX(tmr_idx); + iq->intr_pktc_idx = SGE_NCOUNTERS - 1; + if (pktc_idx >= 0) { + iq->intr_params |= F_QINTR_CNT_EN; + iq->intr_pktc_idx = pktc_idx; + } iq->qsize = roundup(qsize, 16); /* See FW_IQ_CMD/iqsize */ iq->esize = max(esize, 16); /* See FW_IQ_CMD/iqesize */ strlcpy(iq->lockname, name, sizeof(iq->lockname)); From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 10:22:24 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 122BC106566B; Mon, 30 Apr 2012 10:22:24 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EE7BA8FC18; Mon, 30 Apr 2012 10:22:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UAMNbR060056; Mon, 30 Apr 2012 10:22:23 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UAMNcq060049; Mon, 30 Apr 2012 10:22:23 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201204301022.q3UAMNcq060049@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Mon, 30 Apr 2012 10:22:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 10:22:24 -0000 Author: melifaro Date: Mon Apr 30 10:22:23 2012 New Revision: 234834 URL: http://svn.freebsd.org/changeset/base/234834 Log: Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. Remove ipfw/ip_fw_private.h header from non-ipfw code. Approved by: ae(mentor) MFC after: 2 weeks Modified: head/sys/contrib/pf/net/pf.c head/sys/net/if_bridge.c head/sys/net/if_ethersubr.c head/sys/netinet/ip_fw.h head/sys/netinet/ipfw/ip_fw_private.h head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Modified: head/sys/contrib/pf/net/pf.c ============================================================================== --- head/sys/contrib/pf/net/pf.c Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/contrib/pf/net/pf.c Mon Apr 30 10:22:23 2012 (r234834) @@ -122,7 +122,6 @@ __FBSDID("$FreeBSD$"); #include #ifdef __FreeBSD__ #include -#include /* XXX: only for DIR_IN/DIR_OUT */ #endif #ifndef __FreeBSD__ Modified: head/sys/net/if_bridge.c ============================================================================== --- head/sys/net/if_bridge.c Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/net/if_bridge.c Mon Apr 30 10:22:23 2012 (r234834) @@ -132,7 +132,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include /* * Size of the route hash table. Must be a power of two. Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/net/if_ethersubr.c Mon Apr 30 10:22:23 2012 (r234834) @@ -72,7 +72,6 @@ #include #include #include -#include #endif #ifdef INET6 #include Modified: head/sys/netinet/ip_fw.h ============================================================================== --- head/sys/netinet/ip_fw.h Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/netinet/ip_fw.h Mon Apr 30 10:22:23 2012 (r234834) @@ -545,6 +545,88 @@ struct ipfw_flow_id { #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) +#ifdef _KERNEL +/* Return values from ipfw_[ether_]chk() */ +enum { + IP_FW_PASS = 0, + IP_FW_DENY, + IP_FW_DIVERT, + IP_FW_TEE, + IP_FW_DUMMYNET, + IP_FW_NETGRAPH, + IP_FW_NGTEE, + IP_FW_NAT, + IP_FW_REASS, +}; + +/* + * Hooks sometime need to know the direction of the packet + * (divert, dummynet, netgraph, ...) + * We use a generic definition here, with bit0-1 indicating the + * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the + * specific protocol (if necessary) + */ +enum { + DIR_MASK = 0x3, + DIR_OUT = 0, + DIR_IN = 1, + DIR_FWD = 2, + DIR_DROP = 3, + PROTO_LAYER2 = 0x4, /* set for layer 2 */ + /* PROTO_DEFAULT = 0, */ + PROTO_IPV4 = 0x08, + PROTO_IPV6 = 0x10, + PROTO_IFB = 0x0c, /* layer2 + ifbridge */ + /* PROTO_OLDBDG = 0x14, unused, old bridge */ +}; + +/* + * Structure for collecting parameters to dummynet for ip6_output forwarding + */ +struct _ip6dn_args { + struct ip6_pktopts *opt_or; + struct route_in6 ro_or; + int flags_or; + struct ip6_moptions *im6o_or; + struct ifnet *origifp_or; + struct ifnet *ifp_or; + struct sockaddr_in6 dst_or; + u_long mtu_or; + struct route_in6 ro_pmtu_or; +}; + +/* + * Arguments for calling ipfw_chk() and dummynet_io(). We put them + * all into a structure because this way it is easier and more + * efficient to pass variables around and extend the interface. + */ +struct ip_fw_args { + struct mbuf *m; /* the mbuf chain */ + struct ifnet *oif; /* output interface */ + struct sockaddr_in *next_hop; /* forward address */ + struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ + + /* + * On return, it points to the matching rule. + * On entry, rule.slot > 0 means the info is valid and + * contains the starting rule for an ipfw search. + * If chain_id == chain->id && slot >0 then jump to that slot. + * Otherwise, we locate the first rule >= rulenum:rule_id + */ + struct ipfw_rule_ref rule; /* match/restart info */ + + struct ether_header *eh; /* for bridged packets */ + + struct ipfw_flow_id f_id; /* grabbed from IP header */ + //uint32_t cookie; /* a cookie depending on rule action */ + struct inpcb *inp; + + struct _ip6dn_args dummypar; /* dummynet->ip6_output */ + struct sockaddr_in hopstore; /* store here if cannot use a pointer */ +}; + +#endif /* _KERNEL */ + /* * Dynamic ipfw rule. */ Modified: head/sys/netinet/ipfw/ip_fw_private.h ============================================================================== --- head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 10:22:23 2012 (r234834) @@ -48,89 +48,8 @@ #define SYSEND #endif -/* Return values from ipfw_chk() */ -enum { - IP_FW_PASS = 0, - IP_FW_DENY, - IP_FW_DIVERT, - IP_FW_TEE, - IP_FW_DUMMYNET, - IP_FW_NETGRAPH, - IP_FW_NGTEE, - IP_FW_NAT, - IP_FW_REASS, -}; - -/* - * Structure for collecting parameters to dummynet for ip6_output forwarding - */ -struct _ip6dn_args { - struct ip6_pktopts *opt_or; - struct route_in6 ro_or; - int flags_or; - struct ip6_moptions *im6o_or; - struct ifnet *origifp_or; - struct ifnet *ifp_or; - struct sockaddr_in6 dst_or; - u_long mtu_or; - struct route_in6 ro_pmtu_or; -}; - - -/* - * Arguments for calling ipfw_chk() and dummynet_io(). We put them - * all into a structure because this way it is easier and more - * efficient to pass variables around and extend the interface. - */ -struct ip_fw_args { - struct mbuf *m; /* the mbuf chain */ - struct ifnet *oif; /* output interface */ - struct sockaddr_in *next_hop; /* forward address */ - struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ - - /* - * On return, it points to the matching rule. - * On entry, rule.slot > 0 means the info is valid and - * contains the starting rule for an ipfw search. - * If chain_id == chain->id && slot >0 then jump to that slot. - * Otherwise, we locate the first rule >= rulenum:rule_id - */ - struct ipfw_rule_ref rule; /* match/restart info */ - - struct ether_header *eh; /* for bridged packets */ - - struct ipfw_flow_id f_id; /* grabbed from IP header */ - //uint32_t cookie; /* a cookie depending on rule action */ - struct inpcb *inp; - - struct _ip6dn_args dummypar; /* dummynet->ip6_output */ - struct sockaddr_in hopstore; /* store here if cannot use a pointer */ -}; - MALLOC_DECLARE(M_IPFW); -/* - * Hooks sometime need to know the direction of the packet - * (divert, dummynet, netgraph, ...) - * We use a generic definition here, with bit0-1 indicating the - * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the - * specific protocol - * indicating the protocol (if necessary) - */ -enum { - DIR_MASK = 0x3, - DIR_OUT = 0, - DIR_IN = 1, - DIR_FWD = 2, - DIR_DROP = 3, - PROTO_LAYER2 = 0x4, /* set for layer 2 */ - /* PROTO_DEFAULT = 0, */ - PROTO_IPV4 = 0x08, - PROTO_IPV6 = 0x10, - PROTO_IFB = 0x0c, /* layer2 + ifbridge */ - /* PROTO_OLDBDG = 0x14, unused, old bridge */ -}; - /* wrapper for freeing a packet, in case we need to do more work */ #ifndef FREE_PKT #if defined(__linux__) || defined(_WIN32) Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h ============================================================================== --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 09:46:05 2012 (r234833) +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 10:22:23 2012 (r234834) @@ -68,7 +68,6 @@ #include #include #include -#include #endif #ifdef INET6 #include From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 11:28:18 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C8D31065670; Mon, 30 Apr 2012 11:28:18 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB4218FC18; Mon, 30 Apr 2012 11:28:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UBSHi5063819; Mon, 30 Apr 2012 11:28:17 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UBSHlb063816; Mon, 30 Apr 2012 11:28:17 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301128.q3UBSHlb063816@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 11:28:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234836 - head/lib/libc/stdio X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 11:28:18 -0000 Author: dumbbell Date: Mon Apr 30 11:28:17 2012 New Revision: 234836 URL: http://svn.freebsd.org/changeset/base/234836 Log: Remove incorrect __restrict qualifier on several pointers The typical case was: static __inline int convert_ccl(FILE *fp, char * __restrict p, [...]) { [...] if (p == SUPPRESS_PTR) { [...] } else { [...] } [...] } This qualifier says that the pointer is the only one at that time pointing to the resource. Here, clang considers that "p" will never match "SUPPRESS_PTR" and optimize the if{} block out. This leads to segfaults in programs calling vfscanf(3) and vfwscanf(3) with just the format string (no arguments following it). The following softwares were reported to abort with segmentation fault and this patch fixes it: o cmake o smartd o devel/ORBit2 dim@ opened an LLVM PR to discuss this clang optimization: http://llvm.org/bugs/show_bug.cgi?id=12656 Tested by: bsam@ Modified: head/lib/libc/stdio/vfscanf.c head/lib/libc/stdio/vfwscanf.c Modified: head/lib/libc/stdio/vfscanf.c ============================================================================== --- head/lib/libc/stdio/vfscanf.c Mon Apr 30 11:14:46 2012 (r234835) +++ head/lib/libc/stdio/vfscanf.c Mon Apr 30 11:28:17 2012 (r234836) @@ -125,7 +125,7 @@ static const mbstate_t initial_mbs; */ static __inline int -convert_char(FILE *fp, char * __restrict p, int width) +convert_char(FILE *fp, char * p, int width) { int n; @@ -151,7 +151,7 @@ convert_char(FILE *fp, char * __restrict return (sum); } else { size_t r = __fread(p, 1, width, fp); - + if (r == 0) return (-1); return (r); @@ -179,7 +179,7 @@ convert_wchar(FILE *fp, wchar_t *wcp, in } static __inline int -convert_ccl(FILE *fp, char * __restrict p, int width, const char *ccltab) +convert_ccl(FILE *fp, char * p, int width, const char *ccltab) { char *p0; int n; @@ -249,7 +249,7 @@ convert_wccl(FILE *fp, wchar_t *wcp, int } static __inline int -convert_string(FILE *fp, char * __restrict p, int width) +convert_string(FILE *fp, char * p, int width) { char *p0; int n; @@ -387,7 +387,7 @@ parseint(FILE *fp, char * __restrict buf goto ok; } break; - + /* * x ok iff flag still set & 2nd char (or 3rd char if * we have a sign). Modified: head/lib/libc/stdio/vfwscanf.c ============================================================================== --- head/lib/libc/stdio/vfwscanf.c Mon Apr 30 11:14:46 2012 (r234835) +++ head/lib/libc/stdio/vfwscanf.c Mon Apr 30 11:28:17 2012 (r234836) @@ -138,7 +138,7 @@ static const mbstate_t initial_mbs; */ static __inline int -convert_char(FILE *fp, char * __restrict mbp, int width, locale_t locale) +convert_char(FILE *fp, char * mbp, int width, locale_t locale) { mbstate_t mbs; size_t nconv; @@ -179,7 +179,7 @@ convert_wchar(FILE *fp, wchar_t *wcp, in } static __inline int -convert_ccl(FILE *fp, char * __restrict mbp, int width, const struct ccl *ccl, +convert_ccl(FILE *fp, char * mbp, int width, const struct ccl *ccl, locale_t locale) { mbstate_t mbs; @@ -237,7 +237,7 @@ convert_wccl(FILE *fp, wchar_t *wcp, int } static __inline int -convert_string(FILE *fp, char * __restrict mbp, int width, locale_t locale) +convert_string(FILE *fp, char * mbp, int width, locale_t locale) { mbstate_t mbs; size_t nconv; @@ -372,7 +372,7 @@ parseint(FILE *fp, wchar_t *buf, int wid goto ok; } break; - + /* * x ok iff flag still set & 2nd char (or 3rd char if * we have a sign). From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 11:28:55 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72EFA106566C; Mon, 30 Apr 2012 11:28:55 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id C1C0C8FC16; Mon, 30 Apr 2012 11:28:54 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 405727300A; Mon, 30 Apr 2012 13:48:36 +0200 (CEST) Date: Mon, 30 Apr 2012 13:48:36 +0200 From: Luigi Rizzo To: "Alexander V. Chernikov" , ae@freebsd.org Message-ID: <20120430114836.GA62284@onelab2.iet.unipi.it> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201204301022.q3UAMNcq060049@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 11:28:55 -0000 On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: > Author: melifaro > Date: Mon Apr 30 10:22:23 2012 > New Revision: 234834 > URL: http://svn.freebsd.org/changeset/base/234834 > > Log: > Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. I would be really grateful if you could revert this back and discuss what you wanted to achieve with this change other than saving one entry in the list of includes. As clearly mentioned in the commit logs http://svnweb.freebsd.org/base?view=revision&revision=200580 when i did the last revision of the ipfw+dummynet code i tried to put a strong separation between what is visible in userland (ip_fw.h and ip_dummynet.h) and kernel specific stuff. This way changes in the kernel code do not need to affect userland, modify installed headers and so on. This is why kernel-specific definitions were put in private files. We may discuss on the filename, ip_fw_kernel.h may be a better fit, but merging back kernel and userland defs is a bad design decision. 20-30 years ago there were good reasons to use a single header for all sorts of definitions: user-only, kernel-only, and kernel-userland API. Machines were slow, disks were small, portability was not a big deal. These days none of these conditions apply and keeping things separate helps maintainance and avoid accidental pollution of definitions and their misuse. Besides, keep in mind that ipfw and dummynet are meant to work on multiple platforms so this change is causing portability troubles. cheers luigi > Approved by: ae(mentor) > MFC after: 2 weeks > > Modified: > head/sys/contrib/pf/net/pf.c > head/sys/net/if_bridge.c > head/sys/net/if_ethersubr.c > head/sys/netinet/ip_fw.h > head/sys/netinet/ipfw/ip_fw_private.h > head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h > > Modified: head/sys/contrib/pf/net/pf.c > ============================================================================== > --- head/sys/contrib/pf/net/pf.c Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/contrib/pf/net/pf.c Mon Apr 30 10:22:23 2012 (r234834) > @@ -122,7 +122,6 @@ __FBSDID("$FreeBSD$"); > #include > #ifdef __FreeBSD__ > #include > -#include /* XXX: only for DIR_IN/DIR_OUT */ > #endif > > #ifndef __FreeBSD__ > > Modified: head/sys/net/if_bridge.c > ============================================================================== > --- head/sys/net/if_bridge.c Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/net/if_bridge.c Mon Apr 30 10:22:23 2012 (r234834) > @@ -132,7 +132,6 @@ __FBSDID("$FreeBSD$"); > > #include > #include > -#include > > /* > * Size of the route hash table. Must be a power of two. > > Modified: head/sys/net/if_ethersubr.c > ============================================================================== > --- head/sys/net/if_ethersubr.c Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/net/if_ethersubr.c Mon Apr 30 10:22:23 2012 (r234834) > @@ -72,7 +72,6 @@ > #include > #include > #include > -#include > #endif > #ifdef INET6 > #include > > Modified: head/sys/netinet/ip_fw.h > ============================================================================== > --- head/sys/netinet/ip_fw.h Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/netinet/ip_fw.h Mon Apr 30 10:22:23 2012 (r234834) > @@ -545,6 +545,88 @@ struct ipfw_flow_id { > > #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) > > +#ifdef _KERNEL > +/* Return values from ipfw_[ether_]chk() */ > +enum { > + IP_FW_PASS = 0, > + IP_FW_DENY, > + IP_FW_DIVERT, > + IP_FW_TEE, > + IP_FW_DUMMYNET, > + IP_FW_NETGRAPH, > + IP_FW_NGTEE, > + IP_FW_NAT, > + IP_FW_REASS, > +}; > + > +/* > + * Hooks sometime need to know the direction of the packet > + * (divert, dummynet, netgraph, ...) > + * We use a generic definition here, with bit0-1 indicating the > + * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the > + * specific protocol (if necessary) > + */ > +enum { > + DIR_MASK = 0x3, > + DIR_OUT = 0, > + DIR_IN = 1, > + DIR_FWD = 2, > + DIR_DROP = 3, > + PROTO_LAYER2 = 0x4, /* set for layer 2 */ > + /* PROTO_DEFAULT = 0, */ > + PROTO_IPV4 = 0x08, > + PROTO_IPV6 = 0x10, > + PROTO_IFB = 0x0c, /* layer2 + ifbridge */ > + /* PROTO_OLDBDG = 0x14, unused, old bridge */ > +}; > + > +/* > + * Structure for collecting parameters to dummynet for ip6_output forwarding > + */ > +struct _ip6dn_args { > + struct ip6_pktopts *opt_or; > + struct route_in6 ro_or; > + int flags_or; > + struct ip6_moptions *im6o_or; > + struct ifnet *origifp_or; > + struct ifnet *ifp_or; > + struct sockaddr_in6 dst_or; > + u_long mtu_or; > + struct route_in6 ro_pmtu_or; > +}; > + > +/* > + * Arguments for calling ipfw_chk() and dummynet_io(). We put them > + * all into a structure because this way it is easier and more > + * efficient to pass variables around and extend the interface. > + */ > +struct ip_fw_args { > + struct mbuf *m; /* the mbuf chain */ > + struct ifnet *oif; /* output interface */ > + struct sockaddr_in *next_hop; /* forward address */ > + struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ > + > + /* > + * On return, it points to the matching rule. > + * On entry, rule.slot > 0 means the info is valid and > + * contains the starting rule for an ipfw search. > + * If chain_id == chain->id && slot >0 then jump to that slot. > + * Otherwise, we locate the first rule >= rulenum:rule_id > + */ > + struct ipfw_rule_ref rule; /* match/restart info */ > + > + struct ether_header *eh; /* for bridged packets */ > + > + struct ipfw_flow_id f_id; /* grabbed from IP header */ > + //uint32_t cookie; /* a cookie depending on rule action */ > + struct inpcb *inp; > + > + struct _ip6dn_args dummypar; /* dummynet->ip6_output */ > + struct sockaddr_in hopstore; /* store here if cannot use a pointer */ > +}; > + > +#endif /* _KERNEL */ > + > /* > * Dynamic ipfw rule. > */ > > Modified: head/sys/netinet/ipfw/ip_fw_private.h > ============================================================================== > --- head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/netinet/ipfw/ip_fw_private.h Mon Apr 30 10:22:23 2012 (r234834) > @@ -48,89 +48,8 @@ > #define SYSEND > #endif > > -/* Return values from ipfw_chk() */ > -enum { > - IP_FW_PASS = 0, > - IP_FW_DENY, > - IP_FW_DIVERT, > - IP_FW_TEE, > - IP_FW_DUMMYNET, > - IP_FW_NETGRAPH, > - IP_FW_NGTEE, > - IP_FW_NAT, > - IP_FW_REASS, > -}; > - > -/* > - * Structure for collecting parameters to dummynet for ip6_output forwarding > - */ > -struct _ip6dn_args { > - struct ip6_pktopts *opt_or; > - struct route_in6 ro_or; > - int flags_or; > - struct ip6_moptions *im6o_or; > - struct ifnet *origifp_or; > - struct ifnet *ifp_or; > - struct sockaddr_in6 dst_or; > - u_long mtu_or; > - struct route_in6 ro_pmtu_or; > -}; > - > - > -/* > - * Arguments for calling ipfw_chk() and dummynet_io(). We put them > - * all into a structure because this way it is easier and more > - * efficient to pass variables around and extend the interface. > - */ > -struct ip_fw_args { > - struct mbuf *m; /* the mbuf chain */ > - struct ifnet *oif; /* output interface */ > - struct sockaddr_in *next_hop; /* forward address */ > - struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ > - > - /* > - * On return, it points to the matching rule. > - * On entry, rule.slot > 0 means the info is valid and > - * contains the starting rule for an ipfw search. > - * If chain_id == chain->id && slot >0 then jump to that slot. > - * Otherwise, we locate the first rule >= rulenum:rule_id > - */ > - struct ipfw_rule_ref rule; /* match/restart info */ > - > - struct ether_header *eh; /* for bridged packets */ > - > - struct ipfw_flow_id f_id; /* grabbed from IP header */ > - //uint32_t cookie; /* a cookie depending on rule action */ > - struct inpcb *inp; > - > - struct _ip6dn_args dummypar; /* dummynet->ip6_output */ > - struct sockaddr_in hopstore; /* store here if cannot use a pointer */ > -}; > - > MALLOC_DECLARE(M_IPFW); > > -/* > - * Hooks sometime need to know the direction of the packet > - * (divert, dummynet, netgraph, ...) > - * We use a generic definition here, with bit0-1 indicating the > - * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the > - * specific protocol > - * indicating the protocol (if necessary) > - */ > -enum { > - DIR_MASK = 0x3, > - DIR_OUT = 0, > - DIR_IN = 1, > - DIR_FWD = 2, > - DIR_DROP = 3, > - PROTO_LAYER2 = 0x4, /* set for layer 2 */ > - /* PROTO_DEFAULT = 0, */ > - PROTO_IPV4 = 0x08, > - PROTO_IPV6 = 0x10, > - PROTO_IFB = 0x0c, /* layer2 + ifbridge */ > - /* PROTO_OLDBDG = 0x14, unused, old bridge */ > -}; > - > /* wrapper for freeing a packet, in case we need to do more work */ > #ifndef FREE_PKT > #if defined(__linux__) || defined(_WIN32) > > Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h > ============================================================================== > --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 09:46:05 2012 (r234833) > +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Mon Apr 30 10:22:23 2012 (r234834) > @@ -68,7 +68,6 @@ > #include > #include > #include > -#include > #endif > #ifdef INET6 > #include From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 11:36:18 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 88F05106564A; Mon, 30 Apr 2012 11:36:18 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id E9F2A8FC14; Mon, 30 Apr 2012 11:36:17 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id q3UBaB42019409; Mon, 30 Apr 2012 15:36:11 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id q3UBaA5C019408; Mon, 30 Apr 2012 15:36:10 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Mon, 30 Apr 2012 15:36:10 +0400 From: Gleb Smirnoff To: Luigi Rizzo Message-ID: <20120430113610.GC18777@FreeBSD.org> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20120430114836.GA62284@onelab2.iet.unipi.it> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, "Alexander V. Chernikov" Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 11:36:18 -0000 On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: L> > Author: melifaro L> > Date: Mon Apr 30 10:22:23 2012 L> > New Revision: 234834 L> > URL: http://svn.freebsd.org/changeset/base/234834 L> > L> > Log: L> > Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. L> L> I would be really grateful if you could revert this back and discuss L> what you wanted to achieve with this change other than saving one L> entry in the list of includes. L> L> As clearly mentioned in the commit logs L> L> http://svnweb.freebsd.org/base?view=revision&revision=200580 L> L> when i did the last revision of the ipfw+dummynet code i tried L> to put a strong separation between what is visible in userland L> (ip_fw.h and ip_dummynet.h) and kernel specific stuff. L> This way changes in the kernel code do not need to affect userland, L> modify installed headers and so on. L> L> This is why kernel-specific definitions were put in private files. L> We may discuss on the filename, ip_fw_kernel.h may be a better fit, L> but merging back kernel and userland defs is a bad design decision. L> L> 20-30 years ago there were good reasons to use a single header L> for all sorts of definitions: user-only, kernel-only, and kernel-userland API. L> Machines were slow, disks were small, portability was not a big deal. L> L> These days none of these conditions apply and keeping things L> separate helps maintainance and avoid accidental pollution of L> definitions and their misuse. L> L> Besides, keep in mind that ipfw and dummynet are meant to work L> on multiple platforms so this change is causing portability troubles. Can we split ip_fw_private.h to ip_fw_private.h, and ip_fw_var.h? The former is really private, and the latter is for other kernel modules. -- Totus tuus, Glebius. From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 12:11:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDCD81065673; Mon, 30 Apr 2012 12:11:45 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEF968FC1A; Mon, 30 Apr 2012 12:11:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UCBjnb065201; Mon, 30 Apr 2012 12:11:45 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UCBjna065199; Mon, 30 Apr 2012 12:11:45 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201204301211.q3UCBjna065199@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Mon, 30 Apr 2012 12:11:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234837 - head/lib/libfetch X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 12:11:46 -0000 Author: des Date: Mon Apr 30 12:11:45 2012 New Revision: 234837 URL: http://svn.freebsd.org/changeset/base/234837 Log: Since the socket is non-blocking, it is necessary to use select(2) even when there is no timeout, because read(2) will return immediately if there is no data waiting in the TCP buffer, causing fetch_read() to busy-loop on slow connections. MFC after: 3 weeks Noticed by: Yanhui Shen Modified: head/lib/libfetch/common.c Modified: head/lib/libfetch/common.c ============================================================================== --- head/lib/libfetch/common.c Mon Apr 30 11:28:17 2012 (r234836) +++ head/lib/libfetch/common.c Mon Apr 30 12:11:45 2012 (r234837) @@ -455,11 +455,9 @@ fetch_read(conn_t *conn, char *buf, size struct timeval now, timeout, delta; fd_set readfds; ssize_t rlen, total; - int r; char *start; - if (fetchTimeout) { - FD_ZERO(&readfds); + if (fetchTimeout > 0) { gettimeofday(&timeout, NULL); timeout.tv_sec += fetchTimeout; } @@ -523,23 +521,21 @@ fetch_read(conn_t *conn, char *buf, size return (-1); } // assert(rlen == FETCH_READ_WAIT); - while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) { + FD_ZERO(&readfds); + while (!FD_ISSET(conn->sd, &readfds)) { FD_SET(conn->sd, &readfds); - gettimeofday(&now, NULL); - delta.tv_sec = timeout.tv_sec - now.tv_sec; - delta.tv_usec = timeout.tv_usec - now.tv_usec; - if (delta.tv_usec < 0) { - delta.tv_usec += 1000000; - delta.tv_sec--; - } - if (delta.tv_sec < 0) { - errno = ETIMEDOUT; - fetch_syserr(); - return (-1); + if (fetchTimeout > 0) { + gettimeofday(&now, NULL); + if (!timercmp(&timeout, &now, >)) { + errno = ETIMEDOUT; + fetch_syserr(); + return (-1); + } + timersub(&timeout, &now, &delta); } errno = 0; - r = select(conn->sd + 1, &readfds, NULL, NULL, &delta); - if (r == -1) { + if (select(conn->sd + 1, &readfds, NULL, NULL, + fetchTimeout > 0 ? &delta : NULL) < 0) { if (errno == EINTR) { if (fetchRestartCalls) continue; From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 12:12:49 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F33A71065675; Mon, 30 Apr 2012 12:12:48 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DEE678FC22; Mon, 30 Apr 2012 12:12:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UCCmuc065272; Mon, 30 Apr 2012 12:12:48 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UCCmXc065270; Mon, 30 Apr 2012 12:12:48 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201204301212.q3UCCmXc065270@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Mon, 30 Apr 2012 12:12:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234838 - head/lib/libfetch X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 12:12:49 -0000 Author: des Date: Mon Apr 30 12:12:48 2012 New Revision: 234838 URL: http://svn.freebsd.org/changeset/base/234838 Log: Don't reuse credentials if redirected to a different host. Submitted by: Niels Heinen MFC after: 3 weeks Modified: head/lib/libfetch/http.c Modified: head/lib/libfetch/http.c ============================================================================== --- head/lib/libfetch/http.c Mon Apr 30 12:11:45 2012 (r234837) +++ head/lib/libfetch/http.c Mon Apr 30 12:12:48 2012 (r234838) @@ -1779,7 +1779,9 @@ http_request(struct url *URL, const char DEBUG(fprintf(stderr, "failed to parse new URL\n")); goto ouch; } - if (!*new->user && !*new->pwd) { + + /* Only copy credentials if the host matches */ + if (!strcmp(new->host, url->host) && !*new->user && !*new->pwd) { strcpy(new->user, url->user); strcpy(new->pwd, url->pwd); } From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 12:19:07 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED7DA106566B; Mon, 30 Apr 2012 12:19:07 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mail.ipfw.ru (unknown [IPv6:2a01:4f8:120:6141::2]) by mx1.freebsd.org (Postfix) with ESMTP id 7EBCA8FC12; Mon, 30 Apr 2012 12:19:07 +0000 (UTC) Received: from v6.mpls.in ([2a02:978:2::5] helo=ws.su29.net) by mail.ipfw.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1SOpZR-0002ZB-FE; Mon, 30 Apr 2012 16:19:13 +0400 Message-ID: <4F9E82DA.4030406@FreeBSD.org> Date: Mon, 30 Apr 2012 16:17:30 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0) Gecko/20120121 Thunderbird/9.0 MIME-Version: 1.0 To: Gleb Smirnoff References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> In-Reply-To: <20120430113610.GC18777@FreeBSD.org> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Luigi Rizzo Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 12:19:08 -0000 On 30.04.2012 15:36, Gleb Smirnoff wrote: > On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: > L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: > L> > Author: melifaro > L> > Date: Mon Apr 30 10:22:23 2012 > L> > New Revision: 234834 > L> > URL: http://svn.freebsd.org/changeset/base/234834 > L> > > L> > Log: > L> > Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. > L> > L> I would be really grateful if you could revert this back and discuss > L> what you wanted to achieve with this change other than saving one > L> entry in the list of includes. Changing something inside ip_fw_private.h (for example, locking change) requires changes in several totally unrelated subsystems, which is clearly bad. > L> > L> As clearly mentioned in the commit logs > L> > L> http://svnweb.freebsd.org/base?view=revision&revision=200580 Maybe there are some other possibilities documenting preferred layout other than commit log? Searching 2+yrs commit history is not the best way of finding information. > L> > L> when i did the last revision of the ipfw+dummynet code i tried > L> to put a strong separation between what is visible in userland > L> (ip_fw.h and ip_dummynet.h) and kernel specific stuff. > L> This way changes in the kernel code do not need to affect userland, > L> modify installed headers and so on. > L> > L> This is why kernel-specific definitions were put in private files. Unfortunately, it is not so obvious (at least for me "ip_fw_ _private__.h" looks much like "ipfw private headers, used by ipfw subsystem only", not "kernel ipfw specific stuff"). > L> We may discuss on the filename, ip_fw_kernel.h may be a better fit, Personally I prefer glebius@ suggestion with ip_fw_var.h for such common headers. > L> but merging back kernel and userland defs is a bad design decision. So should style(9) be updated with "_KERNEL define is bad" line to make newcomers aware of this "easy" way ? :) > L> > L> 20-30 years ago there were good reasons to use a single header > L> for all sorts of definitions: user-only, kernel-only, and kernel-userland API. > L> Machines were slow, disks were small, portability was not a big deal. > L> > L> These days none of these conditions apply and keeping things > L> separate helps maintainance and avoid accidental pollution of > L> definitions and their misuse. > L> > L> Besides, keep in mind that ipfw and dummynet are meant to work > L> on multiple platforms so this change is causing portability troubles. > > Can we split ip_fw_private.h to ip_fw_private.h, and ip_fw_var.h? The > former is really private, and the latter is for other kernel modules. From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 13:19:17 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E419B106564A; Mon, 30 Apr 2012 13:19:17 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 631B68FC14; Mon, 30 Apr 2012 13:19:17 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id A0D627300A; Mon, 30 Apr 2012 15:39:04 +0200 (CEST) Date: Mon, 30 Apr 2012 15:39:04 +0200 From: Luigi Rizzo To: "Alexander V. Chernikov" Message-ID: <20120430133904.GA65792@onelab2.iet.unipi.it> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> <4F9E82DA.4030406@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F9E82DA.4030406@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, Gleb Smirnoff , src-committers@FreeBSD.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:19:18 -0000 On Mon, Apr 30, 2012 at 04:17:30PM +0400, Alexander V. Chernikov wrote: > On 30.04.2012 15:36, Gleb Smirnoff wrote: > >On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: > >L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: > >L> > Author: melifaro > >L> > Date: Mon Apr 30 10:22:23 2012 > >L> > New Revision: 234834 > >L> > URL: http://svn.freebsd.org/changeset/base/234834 > >L> > > >L> > Log: > >L> > Move several enums and structures required for L2 filtering from > >ip_fw_private.h to ip_fw.h. > >L> > >L> I would be really grateful if you could revert this back and discuss > >L> what you wanted to achieve with this change other than saving one > >L> entry in the list of includes. > Changing something inside ip_fw_private.h (for example, locking change) > requires changes in several totally unrelated subsystems, which is > clearly bad. There are certainly good reasons to split things even further (as Gleb suggested) so if you want to follow that route and have patches for review i will be glad to discuss that. I am the first one to say that the name ip_fw_private.h is confusing, but at the time i did not feel brave enough to move from a single header (ip_fw.h) to the four (ip_fw.h, ip_fw_user.h, ip_fw_kernel.h, ip_fw_kernel_private.h) that would be needed for proper confinement of information. This said, the change you have made introduce a worse form of header pollution and this is why i am requesting a backout. > >L> > >L> As clearly mentioned in the commit logs > >L> > >L> http://svnweb.freebsd.org/base?view=revision&revision=200580 > Maybe there are some other possibilities documenting preferred layout > other than commit log? Searching 2+yrs commit history is not the best > way of finding information. sure, you could have asked people involved with ipfw development to review this change. Also don't expect a single policy in style(9) to hold for all possible situations: the kernel is huge, it has parts that come from multiple origins in time and space, and sometimes is shared with other OSs as well. Refactoring (such as your changes) should keep that in mind. Let's not make a big deal of this thing: we all make mistakes or have different opinions on how things should be done, and the only way to avoid them is to discuss thing in advance, or be open to resolve things when problems arise. No hard feelings. cheers luigi From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 13:29:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 270D2106566B; Mon, 30 Apr 2012 13:29:22 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 111A48FC17; Mon, 30 Apr 2012 13:29:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UDTLBZ067726; Mon, 30 Apr 2012 13:29:21 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDTLH3067723; Mon, 30 Apr 2012 13:29:21 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204301329.q3UDTLH3067723@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 30 Apr 2012 13:29:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234840 - head/libexec/rtld-elf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:29:22 -0000 Author: kib Date: Mon Apr 30 13:29:21 2012 New Revision: 234840 URL: http://svn.freebsd.org/changeset/base/234840 Log: Split the symlook_obj1 into a loop iterating over the ELF object symbol hash elements, and a helper matched_symbol() which match the given hash entry and request, performing needed type and version checks. Based on dragonflybsd support for GNU hash by John Marino Reviewed by: kan Tested by: bapt MFC after: 2 weeks Modified: head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Apr 30 13:07:21 2012 (r234839) +++ head/libexec/rtld-elf/rtld.c Mon Apr 30 13:29:21 2012 (r234840) @@ -1,7 +1,8 @@ /*- * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra. * Copyright 2003 Alexander Kabaev . - * Copyright 2009, 2010, 2011 Konstantin Belousov . + * Copyright 2009-2012 Konstantin Belousov . + * Copyright 2012 John Marino . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -149,6 +150,8 @@ static int object_match_name(const Obj_ static void ld_utrace_log(int, void *, void *, size_t, int, const char *); static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info); +static bool matched_symbol(SymLook *, const Obj_Entry *, Sym_Match_Result *, + const unsigned long); void r_debug_state(struct r_debug *, struct link_map *) __noinline; @@ -3439,28 +3442,15 @@ symlook_obj(SymLook *req, const Obj_Entr return (mres); } -static int -symlook_obj1(SymLook *req, const Obj_Entry *obj) +/* Symbol match routine common to both hash functions */ +static bool +matched_symbol(SymLook *req, const Obj_Entry *obj, Sym_Match_Result *result, + const unsigned long symnum) { - unsigned long symnum; - const Elf_Sym *vsymp; - Elf_Versym verndx; - int vcount; - - if (obj->buckets == NULL) - return (ESRCH); - - vsymp = NULL; - vcount = 0; - symnum = obj->buckets[req->hash % obj->nbuckets]; - - for (; symnum != STN_UNDEF; symnum = obj->chains[symnum]) { + Elf_Versym verndx; const Elf_Sym *symp; const char *strp; - if (symnum >= obj->nchains) - return (ESRCH); /* Bad object */ - symp = obj->symtab + symnum; strp = obj->strtab + symp->st_name; @@ -3468,103 +3458,128 @@ symlook_obj1(SymLook *req, const Obj_Ent case STT_FUNC: case STT_NOTYPE: case STT_OBJECT: + case STT_COMMON: case STT_GNU_IFUNC: - if (symp->st_value == 0) - continue; + if (symp->st_value == 0) + return (false); /* fallthrough */ case STT_TLS: - if (symp->st_shndx != SHN_UNDEF) - break; + if (symp->st_shndx != SHN_UNDEF) + break; #ifndef __mips__ - else if (((req->flags & SYMLOOK_IN_PLT) == 0) && - (ELF_ST_TYPE(symp->st_info) == STT_FUNC)) - break; + else if (((req->flags & SYMLOOK_IN_PLT) == 0) && + (ELF_ST_TYPE(symp->st_info) == STT_FUNC)) + break; /* fallthrough */ #endif default: - continue; + return (false); } if (req->name[0] != strp[0] || strcmp(req->name, strp) != 0) - continue; + return (false); if (req->ventry == NULL) { - if (obj->versyms != NULL) { - verndx = VER_NDX(obj->versyms[symnum]); - if (verndx > obj->vernum) { - _rtld_error("%s: symbol %s references wrong version %d", - obj->path, obj->strtab + symnum, verndx); - continue; - } - /* - * If we are not called from dlsym (i.e. this is a normal - * relocation from unversioned binary), accept the symbol - * immediately if it happens to have first version after - * this shared object became versioned. Otherwise, if - * symbol is versioned and not hidden, remember it. If it - * is the only symbol with this name exported by the - * shared object, it will be returned as a match at the - * end of the function. If symbol is global (verndx < 2) - * accept it unconditionally. - */ - if ((req->flags & SYMLOOK_DLSYM) == 0 && - verndx == VER_NDX_GIVEN) { - req->sym_out = symp; - req->defobj_out = obj; - return (0); - } - else if (verndx >= VER_NDX_GIVEN) { - if ((obj->versyms[symnum] & VER_NDX_HIDDEN) == 0) { - if (vsymp == NULL) - vsymp = symp; - vcount ++; - } - continue; + if (obj->versyms != NULL) { + verndx = VER_NDX(obj->versyms[symnum]); + if (verndx > obj->vernum) { + _rtld_error( + "%s: symbol %s references wrong version %d", + obj->path, obj->strtab + symnum, verndx); + return (false); + } + /* + * If we are not called from dlsym (i.e. this + * is a normal relocation from unversioned + * binary), accept the symbol immediately if + * it happens to have first version after this + * shared object became versioned. Otherwise, + * if symbol is versioned and not hidden, + * remember it. If it is the only symbol with + * this name exported by the shared object, it + * will be returned as a match by the calling + * function. If symbol is global (verndx < 2) + * accept it unconditionally. + */ + if ((req->flags & SYMLOOK_DLSYM) == 0 && + verndx == VER_NDX_GIVEN) { + result->sym_out = symp; + return (true); + } + else if (verndx >= VER_NDX_GIVEN) { + if ((obj->versyms[symnum] & VER_NDX_HIDDEN) + == 0) { + if (result->vsymp == NULL) + result->vsymp = symp; + result->vcount++; + } + return (false); + } } - } - req->sym_out = symp; - req->defobj_out = obj; - return (0); - } else { - if (obj->versyms == NULL) { + result->sym_out = symp; + return (true); + } + if (obj->versyms == NULL) { if (object_match_name(obj, req->ventry->name)) { - _rtld_error("%s: object %s should provide version %s for " - "symbol %s", obj_rtld.path, obj->path, - req->ventry->name, obj->strtab + symnum); - continue; + _rtld_error("%s: object %s should provide version %s " + "for symbol %s", obj_rtld.path, obj->path, + req->ventry->name, obj->strtab + symnum); + return (false); } - } else { + } else { verndx = VER_NDX(obj->versyms[symnum]); if (verndx > obj->vernum) { - _rtld_error("%s: symbol %s references wrong version %d", - obj->path, obj->strtab + symnum, verndx); - continue; + _rtld_error("%s: symbol %s references wrong version %d", + obj->path, obj->strtab + symnum, verndx); + return (false); } if (obj->vertab[verndx].hash != req->ventry->hash || strcmp(obj->vertab[verndx].name, req->ventry->name)) { - /* - * Version does not match. Look if this is a global symbol - * and if it is not hidden. If global symbol (verndx < 2) - * is available, use it. Do not return symbol if we are - * called by dlvsym, because dlvsym looks for a specific - * version and default one is not what dlvsym wants. - */ - if ((req->flags & SYMLOOK_DLSYM) || - (obj->versyms[symnum] & VER_NDX_HIDDEN) || - (verndx >= VER_NDX_GIVEN)) - continue; + /* + * Version does not match. Look if this is a + * global symbol and if it is not hidden. If + * global symbol (verndx < 2) is available, + * use it. Do not return symbol if we are + * called by dlvsym, because dlvsym looks for + * a specific version and default one is not + * what dlvsym wants. + */ + if ((req->flags & SYMLOOK_DLSYM) || + (verndx >= VER_NDX_GIVEN) || + (obj->versyms[symnum] & VER_NDX_HIDDEN)) + return (false); } - } - req->sym_out = symp; - req->defobj_out = obj; - return (0); } - } - if (vcount == 1) { - req->sym_out = vsymp; - req->defobj_out = obj; - return (0); - } - return (ESRCH); + result->sym_out = symp; + return (true); +} + +static int +symlook_obj1(SymLook *req, const Obj_Entry *obj) +{ + unsigned long symnum; + Sym_Match_Result matchres; + + matchres.sym_out = NULL; + matchres.vsymp = NULL; + matchres.vcount = 0; + + for (symnum = obj->buckets[req->hash % obj->nbuckets]; + symnum != STN_UNDEF; symnum = obj->chains[symnum]) { + if (symnum >= obj->nchains) + return (ESRCH); /* Bad object */ + + if (matched_symbol(req, obj, &matchres, symnum)) { + req->sym_out = matchres.sym_out; + req->defobj_out = obj; + return (0); + } + } + if (matchres.vcount == 1) { + req->sym_out = matchres.vsymp; + req->defobj_out = obj; + return (0); + } + return (ESRCH); } static void Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Mon Apr 30 13:07:21 2012 (r234839) +++ head/libexec/rtld-elf/rtld.h Mon Apr 30 13:29:21 2012 (r234840) @@ -126,6 +126,12 @@ typedef struct Struct_Ver_Entry { const char *file; } Ver_Entry; +typedef struct Struct_Sym_Match_Result { + const Elf_Sym *sym_out; + const Elf_Sym *vsymp; + int vcount; +} Sym_Match_Result; + #define VER_INFO_HIDDEN 0x01 /* From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 13:31:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7182A1065672; Mon, 30 Apr 2012 13:31:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A3208FC14; Mon, 30 Apr 2012 13:31:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UDVBxp067842; Mon, 30 Apr 2012 13:31:11 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UDVBAB067832; Mon, 30 Apr 2012 13:31:11 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204301331.q3UDVBAB067832@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 30 Apr 2012 13:31:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234841 - in head/libexec/rtld-elf: . amd64 arm i386 ia64 powerpc powerpc64 sparc64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 13:31:11 -0000 Author: kib Date: Mon Apr 30 13:31:10 2012 New Revision: 234841 URL: http://svn.freebsd.org/changeset/base/234841 Log: Add GNU hash support for rtld. Based on dragonflybsd support for GNU hash by John Marino Reviewed by: kan Tested by: bapt MFC after: 2 weeks Modified: head/libexec/rtld-elf/amd64/reloc.c head/libexec/rtld-elf/arm/reloc.c head/libexec/rtld-elf/i386/reloc.c head/libexec/rtld-elf/ia64/reloc.c head/libexec/rtld-elf/powerpc/reloc.c head/libexec/rtld-elf/powerpc64/reloc.c head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h head/libexec/rtld-elf/sparc64/reloc.c Modified: head/libexec/rtld-elf/amd64/reloc.c ============================================================================== --- head/libexec/rtld-elf/amd64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/amd64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -132,7 +132,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; Modified: head/libexec/rtld-elf/arm/reloc.c ============================================================================== --- head/libexec/rtld-elf/arm/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/arm/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -328,7 +328,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * The dynamic loader may be called from a thread, we have * limited amounts of stack available so we cannot use alloca(). */ - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize); Modified: head/libexec/rtld-elf/i386/reloc.c ============================================================================== --- head/libexec/rtld-elf/i386/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/i386/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -133,7 +133,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; Modified: head/libexec/rtld-elf/ia64/reloc.c ============================================================================== --- head/libexec/rtld-elf/ia64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/ia64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -104,7 +104,7 @@ alloc_fptrs(Obj_Entry *obj, bool mapped) struct fptr **fptrs; size_t fbytes; - fbytes = obj->nchains * sizeof(struct fptr *); + fbytes = obj->dynsymcount * sizeof(struct fptr *); /* * Avoid malloc, if requested. Happens when relocating @@ -138,7 +138,7 @@ free_fptrs(Obj_Entry *obj, bool mapped) if (fptrs == NULL) return; - fbytes = obj->nchains * sizeof(struct fptr *); + fbytes = obj->dynsymcount * sizeof(struct fptr *); if (mapped) munmap(fptrs, fbytes); else @@ -348,7 +348,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Elf_Rela *relalim; const Elf_Rela *rela; SymCache *cache; - int bytes = obj->nchains * sizeof(SymCache); + int bytes = obj->dynsymcount * sizeof(SymCache); int r = -1; /* Modified: head/libexec/rtld-elf/powerpc/reloc.c ============================================================================== --- head/libexec/rtld-elf/powerpc/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/powerpc/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -299,7 +299,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; Modified: head/libexec/rtld-elf/powerpc64/reloc.c ============================================================================== --- head/libexec/rtld-elf/powerpc64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/powerpc64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -287,7 +287,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry const Elf_Rela *relalim; const Elf_Rela *rela; SymCache *cache; - int bytes = obj->nchains * sizeof(SymCache); + int bytes = obj->dynsymcount * sizeof(SymCache); int r = -1; /* Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/rtld.c Mon Apr 30 13:31:10 2012 (r234841) @@ -133,7 +133,8 @@ static int symlook_global(SymLook *, Don static void symlook_init_from_req(SymLook *, const SymLook *); static int symlook_list(SymLook *, const Objlist *, DoneList *); static int symlook_needed(SymLook *, const Needed_Entry *, DoneList *); -static int symlook_obj1(SymLook *, const Obj_Entry *); +static int symlook_obj1_sysv(SymLook *, const Obj_Entry *); +static int symlook_obj1_gnu(SymLook *, const Obj_Entry *); static void trace_loaded_objects(Obj_Entry *); static void unlink_object(Obj_Entry *); static void unload_object(Obj_Entry *); @@ -150,6 +151,7 @@ static int object_match_name(const Obj_ static void ld_utrace_log(int, void *, void *, size_t, int, const char *); static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info); +static uint32_t gnu_hash(const char *); static bool matched_symbol(SymLook *, const Obj_Entry *, Sym_Match_Result *, const unsigned long); @@ -488,6 +490,9 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_ } digest_dynamic(obj_main, 0); + dbg("%s valid_hash_sysv %d valid_hash_gnu %d dynsymcount %d", + obj_main->path, obj_main->valid_hash_sysv, obj_main->valid_hash_gnu, + obj_main->dynsymcount); linkmap_add(obj_main); linkmap_add(&obj_rtld); @@ -825,6 +830,11 @@ digest_dynamic1(Obj_Entry *obj, int earl Needed_Entry **needed_tail = &obj->needed; Needed_Entry **needed_filtees_tail = &obj->needed_filtees; Needed_Entry **needed_aux_filtees_tail = &obj->needed_aux_filtees; + const Elf_Hashelt *hashtab; + const Elf32_Word *hashval; + Elf32_Word bkt, nmaskwords; + int bloom_size32; + bool nmw_power2; int plttype = DT_REL; *dyn_rpath = NULL; @@ -914,12 +924,35 @@ digest_dynamic1(Obj_Entry *obj, int earl case DT_HASH: { - const Elf_Hashelt *hashtab = (const Elf_Hashelt *) - (obj->relocbase + dynp->d_un.d_ptr); + hashtab = (const Elf_Hashelt *)(obj->relocbase + + dynp->d_un.d_ptr); obj->nbuckets = hashtab[0]; obj->nchains = hashtab[1]; obj->buckets = hashtab + 2; obj->chains = obj->buckets + obj->nbuckets; + obj->valid_hash_sysv = obj->nbuckets > 0 && obj->nchains > 0 && + obj->buckets != NULL; + } + break; + + case DT_GNU_HASH: + { + hashtab = (const Elf_Hashelt *)(obj->relocbase + + dynp->d_un.d_ptr); + obj->nbuckets_gnu = hashtab[0]; + obj->symndx_gnu = hashtab[1]; + nmaskwords = hashtab[2]; + bloom_size32 = (__ELF_WORD_SIZE / 32) * nmaskwords; + /* Number of bitmask words is required to be power of 2 */ + nmw_power2 = ((nmaskwords & (nmaskwords - 1)) == 0); + obj->maskwords_bm_gnu = nmaskwords - 1; + obj->shift2_gnu = hashtab[3]; + obj->bloom_gnu = (Elf_Addr *) (hashtab + 4); + obj->buckets_gnu = hashtab + 4 + bloom_size32; + obj->chain_zero_gnu = obj->buckets_gnu + obj->nbuckets_gnu - + obj->symndx_gnu; + obj->valid_hash_gnu = nmw_power2 && obj->nbuckets_gnu > 0 && + obj->buckets_gnu != NULL; } break; @@ -1096,6 +1129,22 @@ digest_dynamic1(Obj_Entry *obj, int earl obj->pltrelasize = obj->pltrelsize; obj->pltrelsize = 0; } + + /* Determine size of dynsym table (equal to nchains of sysv hash) */ + if (obj->valid_hash_sysv) + obj->dynsymcount = obj->nchains; + else if (obj->valid_hash_gnu) { + obj->dynsymcount = 0; + for (bkt = 0; bkt < obj->nbuckets_gnu; bkt++) { + if (obj->buckets_gnu[bkt] == 0) + continue; + hashval = &obj->chain_zero_gnu[obj->buckets_gnu[bkt]]; + do + obj->dynsymcount++; + while ((*hashval++ & 1u) == 0); + } + obj->dynsymcount += obj->symndx_gnu; + } } static void @@ -1312,6 +1361,22 @@ elf_hash(const char *name) } /* + * The GNU hash function is the Daniel J. Bernstein hash clipped to 32 bits + * unsigned in case it's implemented with a wider type. + */ +static uint32_t +gnu_hash(const char *s) +{ + uint32_t h; + unsigned char c; + + h = 5381; + for (c = *s; c != '\0'; c = *++s) + h = h * 33 + c; + return (h & 0xffffffff); +} + +/* * Find the library with the given name, and return its full pathname. * The returned string is dynamically allocated. Generates an error * message and returns NULL if the library cannot be found. @@ -1387,7 +1452,7 @@ find_symdef(unsigned long symnum, const * If we have already found this symbol, get the information from * the cache. */ - if (symnum >= refobj->nchains) + if (symnum >= refobj->dynsymcount) return NULL; /* Bad object */ if (cache != NULL && cache[symnum].sym != NULL) { *defobj_out = cache[symnum].obj; @@ -1885,6 +1950,8 @@ do_load_object(int fd, const char *name, object_add_name(obj, name); obj->path = path; digest_dynamic(obj, 0); + dbg("%s valid_hash_sysv %d valid_hash_gnu %d dynsymcount %d", obj->path, + obj->valid_hash_sysv, obj->valid_hash_gnu, obj->dynsymcount); if (obj->z_noopen && (flags & (RTLD_LO_DLOPEN | RTLD_LO_TRACE)) == RTLD_LO_DLOPEN) { dbg("refusing to load non-loadable \"%s\"", obj->path); @@ -2168,8 +2235,8 @@ relocate_objects(Obj_Entry *first, bool if (obj != rtldobj) dbg("relocating \"%s\"", obj->path); - if (obj->nbuckets == 0 || obj->nchains == 0 || obj->buckets == NULL || - obj->symtab == NULL || obj->strtab == NULL) { + if (obj->symtab == NULL || obj->strtab == NULL || + !(obj->valid_hash_sysv || obj->valid_hash_gnu)) { _rtld_error("%s: Shared object has no run-time symbol table", obj->path); return -1; @@ -2841,7 +2908,7 @@ dladdr(const void *addr, Dl_info *info) * Walk the symbol list looking for the symbol whose address is * closest to the address sent in. */ - for (symoffset = 0; symoffset < obj->nchains; symoffset++) { + for (symoffset = 0; symoffset < obj->dynsymcount; symoffset++) { def = obj->symtab + symoffset; /* @@ -3412,7 +3479,15 @@ symlook_obj(SymLook *req, const Obj_Entr SymLook req1; int flags, res, mres; - mres = symlook_obj1(req, obj); + /* + * There is at least one valid hash at this point, and we prefer to use + * the faster GNU version if available. + */ + if (obj->valid_hash_gnu) + mres = symlook_obj1_gnu(req, obj); + else + mres = symlook_obj1_sysv(req, obj); + if (mres == 0) { if (obj->needed_filtees != NULL) { flags = (req->flags & SYMLOOK_EARLY) ? RTLD_LO_EARLY : 0; @@ -3553,8 +3628,13 @@ matched_symbol(SymLook *req, const Obj_E return (true); } +/* + * Search for symbol using SysV hash function. + * obj->buckets is known not to be NULL at this point; the test for this was + * performed with the obj->valid_hash_sysv assignment. + */ static int -symlook_obj1(SymLook *req, const Obj_Entry *obj) +symlook_obj1_sysv(SymLook *req, const Obj_Entry *obj) { unsigned long symnum; Sym_Match_Result matchres; @@ -3582,6 +3662,56 @@ symlook_obj1(SymLook *req, const Obj_Ent return (ESRCH); } +/* Search for symbol using GNU hash function */ +static int +symlook_obj1_gnu(SymLook *req, const Obj_Entry *obj) +{ + Elf_Addr bloom_word; + const Elf32_Word *hashval; + Elf32_Word bucket; + Sym_Match_Result matchres; + unsigned int h1, h2; + unsigned long symnum; + + matchres.sym_out = NULL; + matchres.vsymp = NULL; + matchres.vcount = 0; + + /* Pick right bitmask word from Bloom filter array */ + bloom_word = obj->bloom_gnu[(req->hash_gnu / __ELF_WORD_SIZE) & + obj->maskwords_bm_gnu]; + + /* Calculate modulus word size of gnu hash and its derivative */ + h1 = req->hash_gnu & (__ELF_WORD_SIZE - 1); + h2 = ((req->hash_gnu >> obj->shift2_gnu) & (__ELF_WORD_SIZE - 1)); + + /* Filter out the "definitely not in set" queries */ + if (((bloom_word >> h1) & (bloom_word >> h2) & 1) == 0) + return (ESRCH); + + /* Locate hash chain and corresponding value element*/ + bucket = obj->buckets_gnu[req->hash_gnu % obj->nbuckets_gnu]; + if (bucket == 0) + return (ESRCH); + hashval = &obj->chain_zero_gnu[bucket]; + do { + if (((*hashval ^ req->hash_gnu) >> 1) == 0) { + symnum = hashval - obj->chain_zero_gnu; + if (matched_symbol(req, obj, &matchres, symnum)) { + req->sym_out = matchres.sym_out; + req->defobj_out = obj; + return (0); + } + } + } while ((*hashval++ & 1) == 0); + if (matchres.vcount == 1) { + req->sym_out = matchres.vsymp; + req->defobj_out = obj; + return (0); + } + return (ESRCH); +} + static void trace_loaded_objects(Obj_Entry *obj) { @@ -4365,6 +4495,7 @@ symlook_init(SymLook *dst, const char *n bzero(dst, sizeof(*dst)); dst->name = name; dst->hash = elf_hash(name); + dst->hash_gnu = gnu_hash(name); } static void @@ -4373,6 +4504,7 @@ symlook_init_from_req(SymLook *dst, cons dst->name = src->name; dst->hash = src->hash; + dst->hash_gnu = src->hash_gnu; dst->ventry = src->ventry; dst->flags = src->flags; dst->defobj_out = NULL; Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/rtld.h Mon Apr 30 13:31:10 2012 (r234841) @@ -210,7 +210,16 @@ typedef struct Struct_Obj_Entry { const Elf_Hashelt *buckets; /* Hash table buckets array */ unsigned long nbuckets; /* Number of buckets */ const Elf_Hashelt *chains; /* Hash table chain array */ - unsigned long nchains; /* Number of chains */ + unsigned long nchains; /* Number of entries in chain array */ + + Elf32_Word nbuckets_gnu; /* Number of GNU hash buckets*/ + Elf32_Word symndx_gnu; /* 1st accessible symbol on dynsym table */ + Elf32_Word maskwords_bm_gnu; /* Bloom filter words - 1 (bitmask) */ + Elf32_Word shift2_gnu; /* Bloom filter shift count */ + Elf32_Word dynsymcount; /* Total entries in dynsym table */ + Elf_Addr *bloom_gnu; /* Bloom filter used by GNU hash func */ + const Elf_Hashelt *buckets_gnu; /* GNU hash table bucket array */ + const Elf_Hashelt *chain_zero_gnu; /* GNU hash table value array (Zeroed) */ char *rpath; /* Search path specified in object */ Needed_Entry *needed; /* Shared objects needed by this one (%) */ @@ -257,6 +266,8 @@ typedef struct Struct_Obj_Entry { bool irelative : 1; /* Object has R_MACHDEP_IRELATIVE relocs */ bool gnu_ifunc : 1; /* Object has references to STT_GNU_IFUNC */ bool crt_no_init : 1; /* Object' crt does not call _init/_fini */ + bool valid_hash_sysv : 1; /* A valid System V hash hash tag is available */ + bool valid_hash_gnu : 1; /* A valid GNU hash tag is available */ struct link_map linkmap; /* For GDB and dlinfo() */ Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ @@ -316,6 +327,7 @@ struct Struct_RtldLockState { typedef struct Struct_SymLook { const char *name; unsigned long hash; + uint32_t hash_gnu; const Ver_Entry *ventry; int flags; const Obj_Entry *defobj_out; Modified: head/libexec/rtld-elf/sparc64/reloc.c ============================================================================== --- head/libexec/rtld-elf/sparc64/reloc.c Mon Apr 30 13:29:21 2012 (r234840) +++ head/libexec/rtld-elf/sparc64/reloc.c Mon Apr 30 13:31:10 2012 (r234841) @@ -305,7 +305,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry * limited amounts of stack available so we cannot use alloca(). */ if (obj != obj_rtld) { - cache = calloc(obj->nchains, sizeof(SymCache)); + cache = calloc(obj->dynsymcount, sizeof(SymCache)); /* No need to check for NULL here */ } else cache = NULL; From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 16:08:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8A945106566B; Mon, 30 Apr 2012 16:08:03 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C2CD8FC15; Mon, 30 Apr 2012 16:08:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UG83hO073345; Mon, 30 Apr 2012 16:08:03 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UG83YP073341; Mon, 30 Apr 2012 16:08:03 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201204301608.q3UG83YP073341@svn.freebsd.org> From: Edward Tomasz Napierala Date: Mon, 30 Apr 2012 16:08:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234846 - head/sbin/growfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 16:08:03 -0000 Author: trasz Date: Mon Apr 30 16:08:02 2012 New Revision: 234846 URL: http://svn.freebsd.org/changeset/base/234846 Log: Improve growfs(8) in a few ways; unfortunately, it's somewhat hard to untangle them and commit separately. 1. Rewrite the way growfs(8) finds the device and mount point. This makes it possible to use e.g. "growfs /mnt"; it's also used to display more helpful messages. 2. Be more user-friendly, using descriptive messages, like this: OK to grow filesystem on /dev/md0, mounted on /mnt, from 9.8GB to 20GB? [Yes/No]" 3. Allow to specify the size (-s option) just like with mdconfig(8), i.e. with postfixes ("mdconfig -s 10g"). 4. Reload read-only filesystem after growing. Reviewed by: kib, mckusick (earlier version) Sponsored by: The FreeBSD Foundation Modified: head/sbin/growfs/Makefile head/sbin/growfs/growfs.8 head/sbin/growfs/growfs.c Modified: head/sbin/growfs/Makefile ============================================================================== --- head/sbin/growfs/Makefile Mon Apr 30 15:46:41 2012 (r234845) +++ head/sbin/growfs/Makefile Mon Apr 30 16:08:02 2012 (r234846) @@ -6,12 +6,18 @@ #GFSDBG= +.PATH: ${.CURDIR}/../mount + PROG= growfs -SRCS= growfs.c +SRCS= growfs.c getmntopts.c MAN= growfs.8 +CFLAGS+=-I${.CURDIR}/../mount .if defined(GFSDBG) SRCS+= debug.c .endif +DPADD= ${LIBUTIL} +LDADD= -lutil + .include Modified: head/sbin/growfs/growfs.8 ============================================================================== --- head/sbin/growfs/growfs.8 Mon Apr 30 15:46:41 2012 (r234845) +++ head/sbin/growfs/growfs.8 Mon Apr 30 16:08:02 2012 (r234846) @@ -37,7 +37,7 @@ .\" $TSHeader: src/sbin/growfs/growfs.8,v 1.3 2000/12/12 19:31:00 tomsoft Exp $ .\" $FreeBSD$ .\" -.Dd June 29, 2011 +.Dd April 30, 2012 .Dt GROWFS 8 .Os .Sh NAME @@ -47,41 +47,20 @@ .Nm .Op Fl Ny .Op Fl s Ar size -.Ar special +.Ar special | filesystem .Sh DESCRIPTION The .Nm -utility extends the -.Xr newfs 8 -program. -Before starting -.Nm -the disk must be labeled to a bigger size using -.Xr bsdlabel 8 . -If you wish to grow a file system beyond the boundary of -the slice it resides in, you must re-size the slice using -.Xr gpart 8 -before running -.Nm . +utility makes it possible to expand an UFS file system. +Before running +.Nm +the partition or slice containing the file system must be extended using +.Xr gpart 8 . If you are using volumes you must enlarge them by using .Xr gvinum 8 . The .Nm utility extends the size of the file system on the specified special file. -Currently -.Nm -can only enlarge unmounted file systems. -Do not try enlarging a mounted file system, your system may panic and you will -not be able to use the file system any longer. -Most of the -.Xr newfs 8 -options cannot be changed by -.Nm . -In fact, you can only increase the size of the file system. -Use -.Xr tunefs 8 -for other changes. -.Pp The following options are available: .Bl -tag -width indent .It Fl N @@ -103,6 +82,13 @@ So use this option with great care! Determines the .Ar size of the file system after enlarging in sectors. +.Ar Size +is the number of 512 byte sectors unless suffixed with a +.Cm b , k , m , g , +or +.Cm t +which +denotes byte, kilobyte, megabyte, gigabyte and terabyte respectively. This value defaults to the size of the raw partition specified in .Ar special (in other words, @@ -110,19 +96,18 @@ This value defaults to the size of the r will enlarge the file system to the size of the entire partition). .El .Sh EXAMPLES -.Dl growfs -s 4194304 /dev/vinum/testvol +.Dl growfs -s 2G /dev/ada0p1 .Pp will enlarge -.Pa /dev/vinum/testvol +.Pa /dev/ada0p1 up to 2GB if there is enough space in -.Pa /dev/vinum/testvol . +.Pa /dev/ada0p1 . .Sh SEE ALSO -.Xr bsdlabel 8 , .Xr dumpfs 8 , .Xr ffsinfo 8 , .Xr fsck 8 , +.Xr fsdb 8 , .Xr gpart 8 , -.Xr gvinum 8 , .Xr newfs 8 , .Xr tunefs 8 .Sh HISTORY @@ -134,61 +119,12 @@ utility first appeared in .An Christoph Herrmann Aq chm@FreeBSD.org .An Thomas-Henning von Kamptz Aq tomsoft@FreeBSD.org .An The GROWFS team Aq growfs@Tomsoft.COM +.An Edward Tomasz Napierala Aq trasz@FreeBSD.org .Sh BUGS -The -.Nm -utility works starting with -.Fx -3.x. -There may be cases on -.Fx -3.x only, when -.Nm -does not recognize properly whether or not the file system is mounted and -exits with an error message. -Then please use -.Nm -.Fl y -if you are sure that the file system is not mounted. -It is also recommended to always use -.Xr fsck 8 -after enlarging (just to be on the safe side). -.Pp -For enlarging beyond certain limits, it is essential to have some free blocks -available in the first cylinder group. -If that space is not available in the first cylinder group, a critical data -structure has to be relocated into one of the new available cylinder groups. -On -.Fx -3.x this will cause problems with -.Xr fsck 8 -afterwards. -So -.Xr fsck 8 -needs to be patched if you want to use -.Nm -for -.Fx -3.x. -This patch is already integrated in -.Fx -starting with -.Fx 4.4 . -To avoid an unexpected relocation of that structure it is possible to use -.Nm ffsinfo -.Fl g Ar 0 -.Fl l Ar 4 -on the first cylinder group to verify that -.Em nbfree -in the CYLINDER SUMMARY (internal cs) of the CYLINDER GROUP -.Em cgr0 -has enough blocks. -As a rule of thumb for default file system parameters one block is needed for -every 2 GB of total file system size. .Pp Normally .Nm -writes this critical structure to disk and reads it again later for doing more +writes cylinder group summary to disk and reads it again later for doing more updates. This read operation will provide unexpected data when using .Fl N . Modified: head/sbin/growfs/growfs.c ============================================================================== --- head/sbin/growfs/growfs.c Mon Apr 30 15:46:41 2012 (r234845) +++ head/sbin/growfs/growfs.c Mon Apr 30 16:08:02 2012 (r234846) @@ -1,11 +1,15 @@ /* - * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. + * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz + * Copyright (c) 2012 The FreeBSD Foundation * All rights reserved. * * This code is derived from software contributed to Berkeley by * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt. * + * 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: @@ -53,13 +57,18 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include #include #include +#include +#include #include +#include #include #include #include @@ -67,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "debug.h" @@ -109,7 +119,7 @@ static void updjcg(int, time_t, int, int static void updcsloc(time_t, int, int, unsigned int); static void frag_adjust(ufs2_daddr_t, int); static void updclst(int); -static void get_dev_size(int, int *); +static void mount_reload(const struct statfs *stfs); /* * Here we actually start growing the file system. We basically read the @@ -177,6 +187,7 @@ growfs(int fsi, int fso, unsigned int Nf /* * Dump out summary information about file system. */ +#ifdef FS_DEBUG #define B2MBFACTOR (1 / (1024.0 * 1024.0)) printf("growfs: %.1fMB (%jd sectors) block size %d, fragment size %d\n", (float)sblock.fs_size * sblock.fs_fsize * B2MBFACTOR, @@ -188,6 +199,7 @@ growfs(int fsi, int fso, unsigned int Nf if (sblock.fs_flags & FS_DOSOFTDEP) printf("\twith soft updates\n"); #undef B2MBFACTOR +#endif /* FS_DEBUG */ /* * Now build the cylinders group blocks and @@ -774,7 +786,7 @@ updjcg(int cylno, time_t modtime, int fs /* * Here we update the location of the cylinder summary. We have two possible - * ways of growing the cylinder summary. + * ways of growing the cylinder summary: * (1) We can try to grow the summary in the current location, and relocate * possibly used blocks within the current cylinder group. * (2) Alternatively we can relocate the whole cylinder summary to the first @@ -1238,24 +1250,104 @@ charsperline(void) return (columns); } +static int +is_dev(const char *name) +{ + struct stat devstat; + + if (stat(name, &devstat) != 0) + return (0); + if (!S_ISCHR(devstat.st_mode)) + return (0); + return (1); +} + /* - * Get the size of the partition. - */ -static void -get_dev_size(int fd, int *size) + * Return mountpoint on which the device is currently mounted. + */ +static const struct statfs * +dev_to_statfs(const char *dev) { - int sectorsize; - off_t mediasize; + struct stat devstat, mntdevstat; + struct statfs *mntbuf, *statfsp; + char device[MAXPATHLEN]; + char *mntdevname; + int i, mntsize; + + /* + * First check the mounted filesystems. + */ + if (stat(dev, &devstat) != 0) + return (NULL); + if (!S_ISCHR(devstat.st_mode) && !S_ISBLK(devstat.st_mode)) + return (NULL); + + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + for (i = 0; i < mntsize; i++) { + statfsp = &mntbuf[i]; + mntdevname = statfsp->f_mntfromname; + if (*mntdevname != '/') { + strcpy(device, _PATH_DEV); + strcat(device, mntdevname); + mntdevname = device; + } + if (stat(mntdevname, &mntdevstat) == 0 && + mntdevstat.st_rdev == devstat.st_rdev) + return (statfsp); + } - if (ioctl(fd, DIOCGSECTORSIZE, §orsize) == -1) - err(1,"DIOCGSECTORSIZE"); - if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) == -1) - err(1,"DIOCGMEDIASIZE"); + return (NULL); +} - if (sectorsize <= 0) - errx(1, "bogus sectorsize: %d", sectorsize); +static const char * +mountpoint_to_dev(const char *mountpoint) +{ + struct statfs *mntbuf, *statfsp; + struct fstab *fs; + int i, mntsize; - *size = mediasize / sectorsize; + /* + * First check the mounted filesystems. + */ + mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); + for (i = 0; i < mntsize; i++) { + statfsp = &mntbuf[i]; + + if (strcmp(statfsp->f_mntonname, mountpoint) == 0) + return (statfsp->f_mntfromname); + } + + /* + * Check the fstab. + */ + fs = getfsfile(mountpoint); + if (fs != NULL) + return (fs->fs_spec); + + return (NULL); +} + +static const char * +getdev(const char *name) +{ + static char device[MAXPATHLEN]; + const char *cp, *dev; + + if (is_dev(name)) + return (name); + + cp = strrchr(name, '/'); + if (cp == 0) { + snprintf(device, sizeof(device), "%s%s", _PATH_DEV, name); + if (is_dev(device)) + return (device); + } + + dev = mountpoint_to_dev(name); + if (dev != NULL && is_dev(dev)) + return (dev); + + return (NULL); } /* @@ -1283,17 +1375,13 @@ int main(int argc, char **argv) { DBG_FUNC("main") - char *device, *special; - int ch; - unsigned int size = 0; - size_t len; - unsigned int Nflag = 0; - int ExpertFlag = 0; - struct stat st; - int i, fsi, fso; - u_int32_t p_size; - char reply[5]; - int j; + const char *device; + const struct statfs *statfsp; + uint64_t size = 0; + off_t mediasize; + int error, i, j, fsi, fso, ch, Nflag = 0, yflag = 0; + char *p, reply[5], oldsizebuf[6], newsizebuf[6]; + void *testbuf; DBG_ENTER; @@ -1303,14 +1391,27 @@ main(int argc, char **argv) Nflag = 1; break; case 's': - size = (size_t)atol(optarg); - if (size < 1) - usage(); + size = (off_t)strtoumax(optarg, &p, 0); + if (p == NULL || *p == '\0') + size *= DEV_BSIZE; + else if (*p == 'b' || *p == 'B') + ; /* do nothing */ + else if (*p == 'k' || *p == 'K') + size <<= 10; + else if (*p == 'm' || *p == 'M') + size <<= 20; + else if (*p == 'g' || *p == 'G') + size <<= 30; + else if (*p == 't' || *p == 'T') { + size <<= 30; + size <<= 10; + } else + errx(1, "unknown suffix on -s argument"); break; case 'v': /* for compatibility to newfs */ break; case 'y': - ExpertFlag = 1; + yflag = 1; break; case '?': /* FALLTHROUGH */ @@ -1324,71 +1425,29 @@ main(int argc, char **argv) if (argc != 1) usage(); - device = *argv; - /* - * Now try to guess the (raw)device name. + * Now try to guess the device name. */ - if (0 == strrchr(device, '/')) { - /* - * No path prefix was given, so try in that order: - * /dev/r%s - * /dev/%s - * /dev/vinum/r%s - * /dev/vinum/%s. - * - * FreeBSD now doesn't distinguish between raw and block - * devices any longer, but it should still work this way. - */ - len = strlen(device) + strlen(_PATH_DEV) + 2 + strlen("vinum/"); - special = (char *)malloc(len); - if (special == NULL) - errx(1, "malloc failed"); - snprintf(special, len, "%sr%s", _PATH_DEV, device); - if (stat(special, &st) == -1) { - snprintf(special, len, "%s%s", _PATH_DEV, device); - if (stat(special, &st) == -1) { - snprintf(special, len, "%svinum/r%s", - _PATH_DEV, device); - if (stat(special, &st) == -1) { - /* For now this is the 'last resort' */ - snprintf(special, len, "%svinum/%s", - _PATH_DEV, device); - } - } - } - device = special; - } + device = getdev(*argv); + if (device == NULL) + errx(1, "cannot find special device for %s", *argv); - /* - * Try to access our devices for writing ... - */ - if (Nflag) { - fso = -1; - } else { - fso = open(device, O_WRONLY); - if (fso < 0) - err(1, "%s", device); - } + statfsp = dev_to_statfs(device); - /* - * ... and reading. - */ fsi = open(device, O_RDONLY); if (fsi < 0) err(1, "%s", device); /* - * Try to guess the slice if not specified. This code should guess - * the right thing and avoid to bother the user with the task - * of specifying the option -v on vinum volumes. + * Try to guess the slice size if not specified. */ - get_dev_size(fsi, &p_size); + if (ioctl(fsi, DIOCGMEDIASIZE, &mediasize) == -1) + err(1,"DIOCGMEDIASIZE"); /* * Check if that partition is suitable for growing a file system. */ - if (p_size < 1) + if (mediasize < 1) errx(1, "partition is unavailable"); /* @@ -1414,16 +1473,36 @@ main(int argc, char **argv) /* * Determine size to grow to. Default to the device size. */ - sblock.fs_size = dbtofsb(&osblock, p_size); - if (size != 0) { - if (size > p_size) - errx(1, "there is not enough space (%d < %d)", - p_size, size); - sblock.fs_size = dbtofsb(&osblock, size); + if (size == 0) + size = mediasize; + else { + if (size > (uint64_t)mediasize) { + humanize_number(oldsizebuf, sizeof(oldsizebuf), size, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(newsizebuf, sizeof(newsizebuf), + mediasize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + + errx(1, "requested size %s is larger " + "than the available %s", oldsizebuf, newsizebuf); + } + } + + if (size <= (uint64_t)(osblock.fs_size * osblock.fs_fsize)) { + humanize_number(oldsizebuf, sizeof(oldsizebuf), + osblock.fs_size * osblock.fs_fsize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(newsizebuf, sizeof(newsizebuf), size, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + + errx(1, "requested size %s is not larger than the current " + "filesystem size %s", newsizebuf, oldsizebuf); } + sblock.fs_size = dbtofsb(&osblock, size / DEV_BSIZE); + /* - * Are we really growing ? + * Are we really growing? */ if (osblock.fs_size >= sblock.fs_size) { errx(1, "we are not growing (%jd->%jd)", @@ -1433,7 +1512,7 @@ main(int argc, char **argv) /* * Check if we find an active snapshot. */ - if (ExpertFlag == 0) { + if (yflag == 0) { for (j = 0; j < FSMAXSNAP; j++) { if (sblock.fs_snapinum[j]) { errx(1, "active snapshot found in file system; " @@ -1445,10 +1524,23 @@ main(int argc, char **argv) } } - if (ExpertFlag == 0 && Nflag == 0) { - printf("We strongly recommend you to make a backup " + if (yflag == 0 && Nflag == 0) { + if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) + errx(1, "%s is mounted read-write on %s", + statfsp->f_mntfromname, statfsp->f_mntonname); + printf("It's strongly recommended to make a backup " "before growing the file system.\n" - "Did you backup your data (Yes/No)? "); + "OK to grow filesystem on %s", device); + if (statfsp != NULL) + printf(", mounted on %s,", statfsp->f_mntonname); + humanize_number(oldsizebuf, sizeof(oldsizebuf), + osblock.fs_size * osblock.fs_fsize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(newsizebuf, sizeof(newsizebuf), + sblock.fs_size * sblock.fs_fsize, + "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + printf(" from %s to %s? [Yes/No] ", oldsizebuf, newsizebuf); + fflush(stdout); fgets(reply, (int)sizeof(reply), stdin); if (strcmp(reply, "Yes\n")){ printf("\nNothing done\n"); @@ -1456,15 +1548,30 @@ main(int argc, char **argv) } } - printf("New file system size is %jd frags\n", (intmax_t)sblock.fs_size); + /* + * Try to access our device for writing. If it's not mounted, + * or mounted read-only, simply open it; otherwise, use UFS + * suspension mechanism. + */ + if (Nflag) { + fso = -1; + } else { + fso = open(device, O_WRONLY); + if (fso < 0) + err(1, "%s", device); + } /* - * Try to access our new last block in the file system. Even if we - * later on realize we have to abort our operation, on that block - * there should be no data, so we can't destroy something yet. + * Try to access our new last block in the file system. */ - wtfs((ufs2_daddr_t)p_size - 1, (size_t)DEV_BSIZE, (void *)&sblock, - fso, Nflag); + testbuf = malloc(sblock.fs_fsize); + if (testbuf == NULL) + err(1, "malloc"); + rdfs((ufs2_daddr_t)((size / DEV_BSIZE) - sblock.fs_fsize), + sblock.fs_fsize, testbuf, fsi); + wtfs((ufs2_daddr_t)((size / DEV_BSIZE) - sblock.fs_fsize), + sblock.fs_fsize, testbuf, fso, Nflag); + free(testbuf); /* * Now calculate new superblock values and check for reasonable @@ -1520,8 +1627,13 @@ main(int argc, char **argv) growfs(fsi, fso, Nflag); close(fsi); - if (fso > -1) - close(fso); + if (fso > -1) { + error = close(fso); + if (error != 0) + err(1, "close"); + } + if (statfsp != NULL) + mount_reload(statfsp); DBG_CLOSE; @@ -1539,7 +1651,7 @@ usage(void) DBG_ENTER; - fprintf(stderr, "usage: growfs [-Ny] [-s size] special\n"); + fprintf(stderr, "usage: growfs [-Ny] [-s size] special | filesystem\n"); DBG_LEAVE; exit(1); @@ -1586,3 +1698,26 @@ updclst(int block) DBG_LEAVE; return; } + +static void +mount_reload(const struct statfs *stfs) +{ + char errmsg[255]; + struct iovec *iov; + int iovlen; + + iov = NULL; + iovlen = 0; + *errmsg = '\0'; + build_iovec(&iov, &iovlen, "fstype", __DECONST(char *, "ffs"), 4); + build_iovec(&iov, &iovlen, "fspath", __DECONST(char *, stfs->f_mntonname), (size_t)-1); + build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); + build_iovec(&iov, &iovlen, "update", NULL, 0); + build_iovec(&iov, &iovlen, "reload", NULL, 0); + + if (nmount(iov, iovlen, stfs->f_flags) < 0) { + errmsg[sizeof(errmsg) - 1] = '\0'; + err(9, "%s: cannot reload filesystem%s%s", stfs->f_mntonname, + *errmsg != '\0' ? ": " : "", errmsg); + } +} From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 16:16:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C367C1065676; Mon, 30 Apr 2012 16:16:37 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEDBD8FC08; Mon, 30 Apr 2012 16:16:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UGGbFL073688; Mon, 30 Apr 2012 16:16:37 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UGGbPb073686; Mon, 30 Apr 2012 16:16:37 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201204301616.q3UGGbPb073686@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Mon, 30 Apr 2012 16:16:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234847 - head/share/misc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 16:16:37 -0000 Author: dumbbell Date: Mon Apr 30 16:16:37 2012 New Revision: 234847 URL: http://svn.freebsd.org/changeset/base/234847 Log: Add myself. Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot ============================================================================== --- head/share/misc/committers-src.dot Mon Apr 30 16:08:02 2012 (r234846) +++ head/share/misc/committers-src.dot Mon Apr 30 16:16:37 2012 (r234847) @@ -128,6 +128,7 @@ dg [label="David Greenman\ndg@FreeBSD.or dim [label="Dimitry Andric\ndim@FreeBSD.org\n2010/08/30"] dougb [label="Doug Barton\ndougb@FreeBSD.org\n2000/10/26"] dteske [label="Devin Teske\ndteske@FreeBSD.org\n2012/04/10"] +dumbbell [label="Jean-Sebastien Pedron\ndumbbell@FreeBSD.org\n2004/11/29"] dwmalone [label="David Malone\ndwmalone@FreeBSD.org\n2000/07/11"] ed [label="Ed Schouten\ned@FreeBSD.org\n2008/05/22"] edwin [label="Edwin Groothuis\nedwin@FreeBSD.org\n2007/06/25"] @@ -506,6 +507,7 @@ msmith -> scottl murray -> delphij mux -> cognet +mux -> dumbbell netchild -> ariff From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 17:53:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4109E1065744; Mon, 30 Apr 2012 17:53:03 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B06208FC1E; Mon, 30 Apr 2012 17:53:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UHr2Ht077131; Mon, 30 Apr 2012 17:53:02 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UHr2XI077126; Mon, 30 Apr 2012 17:53:02 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201204301753.q3UHr2XI077126@svn.freebsd.org> From: Alexander Motin Date: Mon, 30 Apr 2012 17:53:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234848 - in head: sbin/geom/class/raid sys/conf sys/geom/raid sys/modules/geom/geom_raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 17:53:03 -0000 Author: mav Date: Mon Apr 30 17:53:02 2012 New Revision: 234848 URL: http://svn.freebsd.org/changeset/base/234848 Log: Add to GEOM RAID class module, supporting the DDF metadata format, as defined by the SNIA Common RAID Disk Data Format Specification v2.0. Supports multiple volumes per array and multiple partitions per disk. Supports standard big-endian and Adaptec's little-endian byte ordering. Supports all single-layer RAID levels. Dual-layer RAID levels except RAID10 are not supported now because of GEOM RAID design limitations. Some work is still to be done, but the present code already manages basic interoperation with RAID BIOS of the Adaptec 1430SA SATA RAID controller. MFC after: 1 month Sponsored by: iXsystems, Inc. Added: head/sys/geom/raid/md_ddf.c (contents, props changed) head/sys/geom/raid/md_ddf.h (contents, props changed) Modified: head/sbin/geom/class/raid/graid.8 head/sys/conf/files head/sys/modules/geom/geom_raid/Makefile Modified: head/sbin/geom/class/raid/graid.8 ============================================================================== --- head/sbin/geom/class/raid/graid.8 Mon Apr 30 16:16:37 2012 (r234847) +++ head/sbin/geom/class/raid/graid.8 Mon Apr 30 17:53:02 2012 (r234848) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 19, 2012 +.Dd April 30, 2012 .Dt GRAID 8 .Os .Sh NAME @@ -200,6 +200,19 @@ The GEOM RAID class follows a modular de formats to be used. Support is currently implemented for the following formats: .Bl -tag -width "Intel" +.It DDF +The format defined by the SNIA Common RAID Disk Data Format v2.0 specification. +Used by some Adaptec RAID BIOSes and some hardware RAID controllers. +Because of high format flexibility different implementations support +different set of features and have different on-disk metadata layouts. +To provide compatibility, the GEOM RAID class mimics capabilities and +metadata layout of the first detected DDF array. +Respecting that, it may support different number of disks per volume, +volumes per array, partitions per disk, etc. +The following configurations are supported: RAID0 (2+ disks), RAID1 (2+ disks), +RAID1E (3+ disks), RAID3 (3+ disks), RAID4 (3+ disks), RAID5 (3+ disks), +RAID5E (4+ disks), RAID5EE (4+ disks), RAID5R (3+ disks), RAID6 (4+ disks), +RAIDMDF (5+ disks), RAID10 (4+ disks), SINGLE (1 disk), CONCAT (2+ disks). .It Intel The format used by Intel RAID BIOS. Supports up to two volumes per array. Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Apr 30 16:16:37 2012 (r234847) +++ head/sys/conf/files Mon Apr 30 17:53:02 2012 (r234848) @@ -2396,6 +2396,7 @@ geom/raid/g_raid.c optional geom_raid geom/raid/g_raid_ctl.c optional geom_raid geom/raid/g_raid_md_if.m optional geom_raid geom/raid/g_raid_tr_if.m optional geom_raid +geom/raid/md_ddf.c optional geom_raid geom/raid/md_intel.c optional geom_raid geom/raid/md_jmicron.c optional geom_raid geom/raid/md_nvidia.c optional geom_raid Added: head/sys/geom/raid/md_ddf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/geom/raid/md_ddf.c Mon Apr 30 17:53:02 2012 (r234848) @@ -0,0 +1,2900 @@ +/*- + * Copyright (c) 2012 Alexander Motin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "geom/raid/g_raid.h" +#include "geom/raid/md_ddf.h" +#include "g_raid_md_if.h" + +static MALLOC_DEFINE(M_MD_DDF, "md_ddf_data", "GEOM_RAID DDF metadata"); + +#define DDF_MAX_DISKS_HARD 128 + +#define DDF_MAX_DISKS 16 +#define DDF_MAX_VDISKS 7 +#define DDF_MAX_PARTITIONS 1 + +#define DECADE (3600*24*(365*10+2)) /* 10 years in seconds. */ + +struct ddf_meta { + u_int sectorsize; + u_int bigendian; + struct ddf_header *hdr; + struct ddf_cd_record *cdr; + struct ddf_pd_record *pdr; + struct ddf_vd_record *vdr; + void *cr; + struct ddf_pdd_record *pdd; + struct ddf_bbm_log *bbm; +}; + +struct ddf_vol_meta { + u_int sectorsize; + u_int bigendian; + struct ddf_header *hdr; + struct ddf_cd_record *cdr; + struct ddf_vd_entry *vde; + struct ddf_vdc_record *vdc; + struct ddf_vdc_record *bvdc[DDF_MAX_DISKS_HARD]; +}; + +struct g_raid_md_ddf_perdisk { + struct ddf_meta pd_meta; +}; + +struct g_raid_md_ddf_pervolume { + struct ddf_vol_meta pv_meta; + int pv_started; + struct callout pv_start_co; /* STARTING state timer. */ +}; + +struct g_raid_md_ddf_object { + struct g_raid_md_object mdio_base; + struct ddf_meta mdio_meta; + struct callout mdio_start_co; /* STARTING state timer. */ + int mdio_started; + int mdio_incomplete; + struct root_hold_token *mdio_rootmount; /* Root mount delay token. */ +}; + +static g_raid_md_create_t g_raid_md_create_ddf; +static g_raid_md_taste_t g_raid_md_taste_ddf; +static g_raid_md_event_t g_raid_md_event_ddf; +static g_raid_md_volume_event_t g_raid_md_volume_event_ddf; +static g_raid_md_ctl_t g_raid_md_ctl_ddf; +static g_raid_md_write_t g_raid_md_write_ddf; +static g_raid_md_fail_disk_t g_raid_md_fail_disk_ddf; +static g_raid_md_free_disk_t g_raid_md_free_disk_ddf; +static g_raid_md_free_volume_t g_raid_md_free_volume_ddf; +static g_raid_md_free_t g_raid_md_free_ddf; + +static kobj_method_t g_raid_md_ddf_methods[] = { + KOBJMETHOD(g_raid_md_create, g_raid_md_create_ddf), + KOBJMETHOD(g_raid_md_taste, g_raid_md_taste_ddf), + KOBJMETHOD(g_raid_md_event, g_raid_md_event_ddf), + KOBJMETHOD(g_raid_md_volume_event, g_raid_md_volume_event_ddf), + KOBJMETHOD(g_raid_md_ctl, g_raid_md_ctl_ddf), + KOBJMETHOD(g_raid_md_write, g_raid_md_write_ddf), + KOBJMETHOD(g_raid_md_fail_disk, g_raid_md_fail_disk_ddf), + KOBJMETHOD(g_raid_md_free_disk, g_raid_md_free_disk_ddf), + KOBJMETHOD(g_raid_md_free_volume, g_raid_md_free_volume_ddf), + KOBJMETHOD(g_raid_md_free, g_raid_md_free_ddf), + { 0, 0 } +}; + +static struct g_raid_md_class g_raid_md_ddf_class = { + "DDF", + g_raid_md_ddf_methods, + sizeof(struct g_raid_md_ddf_object), + .mdc_priority = 100 +}; + +#define GET8(m, f) ((m)->f) +#define GET16(m, f) ((m)->bigendian ? be16dec(&(m)->f) : le16dec(&(m)->f)) +#define GET32(m, f) ((m)->bigendian ? be32dec(&(m)->f) : le32dec(&(m)->f)) +#define GET64(m, f) ((m)->bigendian ? be64dec(&(m)->f) : le64dec(&(m)->f)) +#define GET8D(m, f) (f) +#define GET16D(m, f) ((m)->bigendian ? be16dec(&f) : le16dec(&f)) +#define GET32D(m, f) ((m)->bigendian ? be32dec(&f) : le32dec(&f)) +#define GET64D(m, f) ((m)->bigendian ? be64dec(&f) : le64dec(&f)) +#define GET8P(m, f) (*(f)) +#define GET16P(m, f) ((m)->bigendian ? be16dec(f) : le16dec(f)) +#define GET32P(m, f) ((m)->bigendian ? be32dec(f) : le32dec(f)) +#define GET64P(m, f) ((m)->bigendian ? be64dec(f) : le64dec(f)) + +#define SET8P(m, f, v) \ + (*(f) = (v)) +#define SET16P(m, f, v) \ + do { \ + if ((m)->bigendian) \ + be16enc((f), (v)); \ + else \ + le16enc((f), (v)); \ + } while (0) +#define SET32P(m, f, v) \ + do { \ + if ((m)->bigendian) \ + be32enc((f), (v)); \ + else \ + le32enc((f), (v)); \ + } while (0) +#define SET64P(m, f, v) \ + do { \ + if ((m)->bigendian) \ + be64enc((f), (v)); \ + else \ + le64enc((f), (v)); \ + } while (0) +#define SET8(m, f, v) SET8P((m), &((m)->f), (v)) +#define SET16(m, f, v) SET16P((m), &((m)->f), (v)) +#define SET32(m, f, v) SET32P((m), &((m)->f), (v)) +#define SET64(m, f, v) SET64P((m), &((m)->f), (v)) +#define SET8D(m, f, v) SET8P((m), &(f), (v)) +#define SET16D(m, f, v) SET16P((m), &(f), (v)) +#define SET32D(m, f, v) SET32P((m), &(f), (v)) +#define SET64D(m, f, v) SET64P((m), &(f), (v)) + +static int +isff(uint8_t *buf, int size) +{ + int i; + + for (i = 0; i < size; i++) + if (buf[i] != 0xff) + return (0); + return (1); +} + +static void +print_guid(uint8_t *buf) +{ + int i, ascii; + + ascii = 1; + for (i = 0; i < 24; i++) { + if (buf[i] != 0 && (buf[i] < ' ' || buf[i] > 127)) { + ascii = 0; + break; + } + } + if (ascii) { + printf("'%.24s'", buf); + } else { + for (i = 0; i < 24; i++) + printf("%02x", buf[i]); + } +} + +static void +g_raid_md_ddf_print(struct ddf_meta *meta) +{ + struct ddf_vdc_record *vdc; + struct ddf_vuc_record *vuc; + struct ddf_sa_record *sa; + uint64_t *val2; + uint32_t val; + int i, j, k, num, num2; + + if (g_raid_debug < 1) + return; + + printf("********* DDF Metadata *********\n"); + printf("**** Header ****\n"); + printf("DDF_Header_GUID "); + print_guid(meta->hdr->DDF_Header_GUID); + printf("\n"); + printf("DDF_rev %8.8s\n", (char *)&meta->hdr->DDF_rev[0]); + printf("Sequence_Number 0x%08x\n", GET32(meta, hdr->Sequence_Number)); + printf("TimeStamp 0x%08x\n", GET32(meta, hdr->TimeStamp)); + printf("Open_Flag 0x%02x\n", GET16(meta, hdr->Open_Flag)); + printf("Foreign_Flag 0x%02x\n", GET16(meta, hdr->Foreign_Flag)); + printf("Diskgrouping 0x%02x\n", GET16(meta, hdr->Diskgrouping)); + printf("Primary_Header_LBA %ju\n", GET64(meta, hdr->Primary_Header_LBA)); + printf("Secondary_Header_LBA %ju\n", GET64(meta, hdr->Secondary_Header_LBA)); + printf("WorkSpace_Length %u\n", GET32(meta, hdr->WorkSpace_Length)); + printf("WorkSpace_LBA %ju\n", GET64(meta, hdr->WorkSpace_LBA)); + printf("Max_PD_Entries %u\n", GET16(meta, hdr->Max_PD_Entries)); + printf("Max_VD_Entries %u\n", GET16(meta, hdr->Max_VD_Entries)); + printf("Max_Partitions %u\n", GET16(meta, hdr->Max_Partitions)); + printf("Configuration_Record_Length %u\n", GET16(meta, hdr->Configuration_Record_Length)); + printf("Max_Primary_Element_Entries %u\n", GET16(meta, hdr->Max_Primary_Element_Entries)); + printf("Controller Data %u:%u\n", GET32(meta, hdr->cd_section), GET32(meta, hdr->cd_length)); + printf("Physical Disk %u:%u\n", GET32(meta, hdr->pdr_section), GET32(meta, hdr->pdr_length)); + printf("Virtual Disk %u:%u\n", GET32(meta, hdr->vdr_section), GET32(meta, hdr->vdr_length)); + printf("Configuration Recs %u:%u\n", GET32(meta, hdr->cr_section), GET32(meta, hdr->cr_length)); + printf("Physical Disk Recs %u:%u\n", GET32(meta, hdr->pdd_section), GET32(meta, hdr->pdd_length)); + printf("BBM Log %u:%u\n", GET32(meta, hdr->bbmlog_section), GET32(meta, hdr->bbmlog_length)); + printf("Diagnostic Space %u:%u\n", GET32(meta, hdr->Diagnostic_Space), GET32(meta, hdr->Diagnostic_Space_Length)); + printf("Vendor_Specific_Logs %u:%u\n", GET32(meta, hdr->Vendor_Specific_Logs), GET32(meta, hdr->Vendor_Specific_Logs_Length)); + printf("**** Controler Data ****\n"); + printf("Controller_GUID "); + print_guid(meta->cdr->Controller_GUID); + printf("\n"); + printf("Controller_Type 0x%04x%04x 0x%04x%04x\n", + GET16(meta, cdr->Controller_Type.Vendor_ID), + GET16(meta, cdr->Controller_Type.Device_ID), + GET16(meta, cdr->Controller_Type.SubVendor_ID), + GET16(meta, cdr->Controller_Type.SubDevice_ID)); + printf("Product_ID '%.16s'\n", (char *)&meta->cdr->Product_ID[0]); + printf("**** Physical Disk Data ****\n"); + printf("Populated_PDEs %u\n", GET16(meta, pdr->Populated_PDEs)); + printf("Max_PDE_Supported %u\n", GET16(meta, pdr->Max_PDE_Supported)); + for (j = 0; j < GET16(meta, pdr->Populated_PDEs); j++) { + if (isff(meta->pdr->entry[j].PD_GUID, 24)) + continue; + if (GET32(meta, pdr->entry[j].PD_Reference) == 0xffffffff) + continue; + printf("PD_GUID "); + print_guid(meta->pdr->entry[j].PD_GUID); + printf("\n"); + printf("PD_Reference 0x%08x\n", + GET32(meta, pdr->entry[j].PD_Reference)); + printf("PD_Type 0x%04x\n", + GET16(meta, pdr->entry[j].PD_Type)); + printf("PD_State 0x%04x\n", + GET16(meta, pdr->entry[j].PD_State)); + printf("Configured_Size %ju\n", + GET64(meta, pdr->entry[j].Configured_Size)); + printf("Block_Size %u\n", + GET16(meta, pdr->entry[j].Block_Size)); + } + printf("**** Virtual Disk Data ****\n"); + printf("Populated_VDEs %u\n", GET16(meta, vdr->Populated_VDEs)); + printf("Max_VDE_Supported %u\n", GET16(meta, vdr->Max_VDE_Supported)); + for (j = 0; j < GET16(meta, vdr->Populated_VDEs); j++) { + if (isff(meta->vdr->entry[j].VD_GUID, 24)) + continue; + printf("VD_GUID "); + print_guid(meta->vdr->entry[j].VD_GUID); + printf("\n"); + printf("VD_Number 0x%04x\n", + GET16(meta, vdr->entry[j].VD_Number)); + printf("VD_Type 0x%02x\n", + GET8(meta, vdr->entry[j].VD_Type)); + printf("VD_State 0x%02x\n", + GET8(meta, vdr->entry[j].VD_State)); + printf("Init_State 0x%02x\n", + GET8(meta, vdr->entry[j].Init_State)); + printf("Drive_Failures_Remaining %u\n", + GET8(meta, vdr->entry[j].Drive_Failures_Remaining)); + printf("VD_Name '%.16s'\n", + (char *)&meta->vdr->entry[j].VD_Name); + } + printf("**** Configuration Records ****\n"); + num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + for (j = 0; j < num; j++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + j * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + val = GET32D(meta, vdc->Signature); + switch (val) { + case DDF_VDCR_SIGNATURE: + printf("** Virtual Disk Configuration **\n"); + printf("VD_GUID "); + print_guid(vdc->VD_GUID); + printf("\n"); + printf("Timestamp 0x%08x\n", + GET32D(meta, vdc->Timestamp)); + printf("Sequence_Number 0x%08x\n", + GET32D(meta, vdc->Sequence_Number)); + printf("Primary_Element_Count %u\n", + GET16D(meta, vdc->Primary_Element_Count)); + printf("Stripe_Size %u\n", + GET8D(meta, vdc->Stripe_Size)); + printf("Primary_RAID_Level 0x%02x\n", + GET8D(meta, vdc->Primary_RAID_Level)); + printf("RLQ 0x%02x\n", + GET8D(meta, vdc->RLQ)); + printf("Secondary_Element_Count %u\n", + GET8D(meta, vdc->Secondary_Element_Count)); + printf("Secondary_Element_Seq %u\n", + GET8D(meta, vdc->Secondary_Element_Seq)); + printf("Secondary_RAID_Level 0x%02x\n", + GET8D(meta, vdc->Secondary_RAID_Level)); + printf("Block_Count %ju\n", + GET64D(meta, vdc->Block_Count)); + printf("VD_Size %ju\n", + GET64D(meta, vdc->VD_Size)); + printf("Block_Size %u\n", + GET16D(meta, vdc->Block_Size)); + printf("Rotate_Parity_count %u\n", + GET8D(meta, vdc->Rotate_Parity_count)); + printf("Associated_Spare_Disks"); + for (i = 0; i < 8; i++) { + if (GET32D(meta, vdc->Associated_Spares[i]) != 0xffffffff) + printf(" 0x%08x", GET32D(meta, vdc->Associated_Spares[i])); + } + printf("\n"); + printf("Cache_Flags %016jx\n", + GET64D(meta, vdc->Cache_Flags)); + printf("BG_Rate %u\n", + GET8D(meta, vdc->BG_Rate)); + printf("MDF_Parity_Disks %u\n", + GET8D(meta, vdc->MDF_Parity_Disks)); + printf("MDF_Parity_Generator_Polynomial 0x%04x\n", + GET16D(meta, vdc->MDF_Parity_Generator_Polynomial)); + printf("MDF_Constant_Generation_Method 0x%02x\n", + GET8D(meta, vdc->MDF_Constant_Generation_Method)); + printf("Physical_Disks "); + num2 = GET16D(meta, vdc->Primary_Element_Count); + val2 = (uint64_t *)&(vdc->Physical_Disk_Sequence[GET16(meta, hdr->Max_Primary_Element_Entries)]); + for (i = 0; i < num2; i++) + printf(" 0x%08x @ %ju", + GET32D(meta, vdc->Physical_Disk_Sequence[i]), + GET64P(meta, val2 + i)); + printf("\n"); + break; + case DDF_VUCR_SIGNATURE: + printf("** Vendor Unique Configuration **\n"); + vuc = (struct ddf_vuc_record *)vdc; + printf("VD_GUID "); + print_guid(vuc->VD_GUID); + printf("\n"); + break; + case DDF_SA_SIGNATURE: + printf("** Spare Assignment Configuration **\n"); + sa = (struct ddf_sa_record *)vdc; + printf("Timestamp 0x%08x\n", + GET32D(meta, sa->Timestamp)); + printf("Spare_Type 0x%02x\n", + GET8D(meta, sa->Spare_Type)); + printf("Populated_SAEs %u\n", + GET16D(meta, sa->Populated_SAEs)); + printf("MAX_SAE_Supported %u\n", + GET16D(meta, sa->MAX_SAE_Supported)); + for (i = 0; i < GET16D(meta, sa->Populated_SAEs); i++) { + if (isff(sa->entry[i].VD_GUID, 24)) + continue; + printf("VD_GUID "); + for (k = 0; k < 24; k++) + printf("%02x", sa->entry[i].VD_GUID[k]); + printf("\n"); + printf("Secondary_Element %u\n", + GET16D(meta, sa->entry[i].Secondary_Element)); + } + break; + case 0xFFFFFFFF: + break; + default: + printf("Unknown configuration signature %08x\n", val); + break; + } + } + printf("**** Physical Disk Data ****\n"); + printf("PD_GUID "); + print_guid(meta->pdd->PD_GUID); + printf("\n"); + printf("PD_Reference 0x%08x\n", + GET32(meta, pdd->PD_Reference)); + printf("Forced_Ref_Flag 0x%02x\n", + GET8(meta, pdd->Forced_Ref_Flag)); + printf("Forced_PD_GUID_Flag 0x%02x\n", + GET8(meta, pdd->Forced_PD_GUID_Flag)); +} + +static int +ddf_meta_find_pd(struct ddf_meta *meta, uint8_t *GUID, uint32_t PD_Reference) +{ + int i; + + for (i = 0; i < GET16(meta, pdr->Populated_PDEs); i++) { + if (GUID != NULL) { + if (memcmp(meta->pdr->entry[i].PD_GUID, GUID, 24) == 0) + return (i); + } else if (PD_Reference != 0xffffffff) { + if (GET32(meta, pdr->entry[i].PD_Reference) == PD_Reference) + return (i); + } else + if (isff(meta->pdr->entry[i].PD_GUID, 24)) + return (i); + } + if (GUID == NULL && PD_Reference == 0xffffffff) { + if (i >= GET16(meta, pdr->Max_PDE_Supported)) + return (-1); + SET16(meta, pdr->Populated_PDEs, i + 1); + return (i); + } + return (-1); +} + +static int +ddf_meta_find_vd(struct ddf_meta *meta, uint8_t *GUID) +{ + int i; + + for (i = 0; i < GET16(meta, vdr->Populated_VDEs); i++) { + if (GUID != NULL) { + if (memcmp(meta->vdr->entry[i].VD_GUID, GUID, 24) == 0) + return (i); + } else + if (isff(meta->vdr->entry[i].VD_GUID, 24)) + return (i); + } + if (GUID == NULL) { + if (i >= GET16(meta, vdr->Max_VDE_Supported)) + return (-1); + SET16(meta, vdr->Populated_VDEs, i + 1); + return (i); + } + return (-1); +} + +static struct ddf_vdc_record * +ddf_meta_find_vdc(struct ddf_meta *meta, uint8_t *GUID) +{ + struct ddf_vdc_record *vdc; + int i, num; + + num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + for (i = 0; i < num; i++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + i * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + if (GUID != NULL) { + if (GET32D(meta, vdc->Signature) == DDF_VDCR_SIGNATURE && + memcmp(vdc->VD_GUID, GUID, 24) == 0) + return (vdc); + } else + if (GET32D(meta, vdc->Signature) == 0xffffffff) + return (vdc); + } + return (NULL); +} + +static int +ddf_meta_count_vdc(struct ddf_meta *meta, uint8_t *GUID) +{ + struct ddf_vdc_record *vdc; + int i, num, cnt; + + cnt = 0; + num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + for (i = 0; i < num; i++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + i * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) + continue; + if (GUID == NULL || memcmp(vdc->VD_GUID, GUID, 24) == 0) + cnt++; + } + return (cnt); +} + +static int +ddf_meta_find_disk(struct ddf_vol_meta *vmeta, uint32_t PD_Reference, + int *bvdp, int *posp) +{ + int i, bvd, pos; + + i = 0; + for (bvd = 0; bvd < GET16(vmeta, vdc->Secondary_Element_Count); bvd++) { + if (vmeta->bvdc[bvd] == NULL) { + i += GET16(vmeta, vdc->Primary_Element_Count); // XXX + continue; + } + for (pos = 0; pos < GET16(vmeta, bvdc[bvd]->Primary_Element_Count); + pos++, i++) { + if (GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos]) == + PD_Reference) { + if (bvdp != NULL) + *bvdp = bvd; + if (posp != NULL) + *posp = pos; + return (i); + } + } + } + return (-1); +} + +static void +ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample) +{ + struct timespec ts; + struct clocktime ct; + struct g_raid_md_ddf_perdisk *pd; + struct ddf_meta *meta; + struct ddf_pd_entry *pde; + off_t anchorlba; + u_int ss, pos, size; + int len, error; + char serial_buffer[24]; + + if (sample->hdr == NULL) + sample = NULL; + + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + meta = &pd->pd_meta; + ss = disk->d_consumer->provider->sectorsize; + anchorlba = disk->d_consumer->provider->mediasize / ss - 1; + + meta->sectorsize = ss; + meta->bigendian = sample ? sample->bigendian : 0; + getnanotime(&ts); + clock_ts_to_ct(&ts, &ct); + + /* Header */ + meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memset(meta->hdr, 0xff, ss); + if (sample) { + memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header)); + if (ss != sample->sectorsize) { + SET32(meta, hdr->WorkSpace_Length, + (GET32(sample, hdr->WorkSpace_Length) * + sample->sectorsize + ss - 1) / ss); + SET16(meta, hdr->Configuration_Record_Length, + (GET16(sample, hdr->Configuration_Record_Length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->cd_length, + (GET32(sample, hdr->cd_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->pdr_length, + (GET32(sample, hdr->pdr_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->vdr_length, + (GET32(sample, hdr->vdr_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->cr_length, + (GET32(sample, hdr->cr_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->pdd_length, + (GET32(sample, hdr->pdd_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->bbmlog_length, + (GET32(sample, hdr->bbmlog_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->Diagnostic_Space, + (GET32(sample, hdr->bbmlog_length) * + sample->sectorsize + ss - 1) / ss); + SET32(meta, hdr->Vendor_Specific_Logs, + (GET32(sample, hdr->bbmlog_length) * + sample->sectorsize + ss - 1) / ss); + } + } else { + SET32(meta, hdr->Signature, DDF_HEADER_SIGNATURE); + snprintf(meta->hdr->DDF_Header_GUID, 25, "FreeBSD %08x%08x", + (u_int)(ts.tv_sec - DECADE), arc4random()); + memcpy(meta->hdr->DDF_rev, "02.00.00", 8); + SET32(meta, hdr->TimeStamp, (ts.tv_sec - DECADE)); + SET32(meta, hdr->WorkSpace_Length, 16 * 1024 * 1024 / ss); + SET16(meta, hdr->Max_PD_Entries, DDF_MAX_DISKS - 1); + SET16(meta, hdr->Max_VD_Entries, DDF_MAX_VDISKS); + SET16(meta, hdr->Max_Partitions, DDF_MAX_PARTITIONS); + SET16(meta, hdr->Max_Primary_Element_Entries, DDF_MAX_DISKS); + SET16(meta, hdr->Configuration_Record_Length, + (sizeof(struct ddf_vdc_record) + + (4 + 8) * GET16(meta, hdr->Max_Primary_Element_Entries) + + ss - 1) / ss); + SET32(meta, hdr->cd_length, + (sizeof(struct ddf_cd_record) + ss - 1) / ss); + SET32(meta, hdr->pdr_length, + (sizeof(struct ddf_pd_record) + + sizeof(struct ddf_pd_entry) * + GET16(meta, hdr->Max_PD_Entries) + ss - 1) / ss); + SET32(meta, hdr->vdr_length, + (sizeof(struct ddf_vd_record) + + sizeof(struct ddf_vd_entry) * + GET16(meta, hdr->Max_VD_Entries) + ss - 1) / ss); + SET32(meta, hdr->cr_length, + GET16(meta, hdr->Configuration_Record_Length) * + (GET16(meta, hdr->Max_Partitions) + 1)); + SET32(meta, hdr->pdd_length, + (sizeof(struct ddf_pdd_record) + ss - 1) / ss); + SET32(meta, hdr->bbmlog_length, 0); + SET32(meta, hdr->Diagnostic_Space_Length, 0); + SET32(meta, hdr->Vendor_Specific_Logs_Length, 0); + } + pos = 1; + SET32(meta, hdr->cd_section, pos); + pos += GET32(meta, hdr->cd_length); + SET32(meta, hdr->pdr_section, pos); + pos += GET32(meta, hdr->pdr_length); + SET32(meta, hdr->vdr_section, pos); + pos += GET32(meta, hdr->vdr_length); + SET32(meta, hdr->cr_section, pos); + pos += GET32(meta, hdr->cr_length); + SET32(meta, hdr->pdd_section, pos); + pos += GET32(meta, hdr->pdd_length); + SET32(meta, hdr->bbmlog_section, + GET32(meta, hdr->bbmlog_length) != 0 ? pos : 0xffffffff); + pos += GET32(meta, hdr->bbmlog_length); + SET32(meta, hdr->Diagnostic_Space, + GET32(meta, hdr->Diagnostic_Space_Length) != 0 ? pos : 0xffffffff); + pos += GET32(meta, hdr->Diagnostic_Space_Length); + SET32(meta, hdr->Vendor_Specific_Logs, + GET32(meta, hdr->Vendor_Specific_Logs_Length) != 0 ? pos : 0xffffffff); + pos += GET32(meta, hdr->Vendor_Specific_Logs_Length); + SET64(meta, hdr->Primary_Header_LBA, + anchorlba - pos - 16); + SET64(meta, hdr->Secondary_Header_LBA, + 0xffffffffffffffffULL); + SET64(meta, hdr->WorkSpace_LBA, + anchorlba + 1 - 32 * 1024 * 1024 / ss); + + /* Controller Data */ + size = GET32(meta, hdr->cd_length) * ss; + meta->cdr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->cdr, 0xff, size); + SET32(meta, cdr->Signature, DDF_CONTROLLER_DATA_SIGNATURE); + memcpy(meta->cdr->Controller_GUID, "FreeBSD GEOM RAID SERIAL", 24); + memcpy(meta->cdr->Product_ID, "FreeBSD GEOMRAID", 16); + + /* Physical Drive Records. */ + size = GET32(meta, hdr->pdr_length) * ss; + meta->pdr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->pdr, 0xff, size); + SET32(meta, pdr->Signature, DDF_PDR_SIGNATURE); + SET16(meta, pdr->Populated_PDEs, 1); + SET16(meta, pdr->Max_PDE_Supported, + GET16(meta, hdr->Max_PD_Entries)); + + pde = &meta->pdr->entry[0]; + len = sizeof(serial_buffer); + error = g_io_getattr("GEOM::ident", disk->d_consumer, &len, serial_buffer); + if (error == 0 && (len = strlen (serial_buffer)) >= 6 && len <= 20) + snprintf(pde->PD_GUID, 25, "DISK%20s", serial_buffer); + else + snprintf(pde->PD_GUID, 25, "DISK%04d%02d%02d%08x%04x", + ct.year, ct.mon, ct.day, + arc4random(), arc4random() & 0xffff); + SET32D(meta, pde->PD_Reference, arc4random()); + SET16D(meta, pde->PD_Type, DDF_PDE_GUID_FORCE); + SET16D(meta, pde->PD_State, 0); + SET64D(meta, pde->Configured_Size, + anchorlba + 1 - 32 * 1024 * 1024 / ss); + SET16D(meta, pde->Block_Size, ss); + + /* Virtual Drive Records. */ + size = GET32(meta, hdr->vdr_length) * ss; + meta->vdr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->vdr, 0xff, size); + SET32(meta, vdr->Signature, DDF_VD_RECORD_SIGNATURE); + SET32(meta, vdr->Populated_VDEs, 0); + SET16(meta, vdr->Max_VDE_Supported, + GET16(meta, hdr->Max_VD_Entries)); + + /* Configuration Records. */ + size = GET32(meta, hdr->cr_length) * ss; + meta->cr = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->cr, 0xff, size); + + /* Physical Disk Data. */ + size = GET32(meta, hdr->pdd_length) * ss; + meta->pdd = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->pdd, 0xff, size); + SET32(meta, pdd->Signature, DDF_PDD_SIGNATURE); + memcpy(meta->pdd->PD_GUID, pde->PD_GUID, 24); + SET32(meta, pdd->PD_Reference, GET32D(meta, pde->PD_Reference)); + SET8(meta, pdd->Forced_Ref_Flag, DDF_PDD_FORCED_REF); + SET8(meta, pdd->Forced_PD_GUID_Flag, DDF_PDD_FORCED_GUID); + + /* Bad Block Management Log. */ + if (GET32(meta, hdr->bbmlog_length) != 0) { + size = GET32(meta, hdr->bbmlog_length) * ss; + meta->bbm = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->bbm, 0xff, size); + SET32(meta, bbm->Signature, DDF_BBML_SIGNATURE); + SET32(meta, bbm->Entry_Count, 0); + SET32(meta, bbm->Spare_Block_Count, 0); + } +} + +static void +ddf_meta_copy(struct ddf_meta *dst, struct ddf_meta *src) +{ + struct ddf_header *hdr; + u_int ss; + + hdr = src->hdr; + dst->bigendian = src->bigendian; + ss = dst->sectorsize = src->sectorsize; + dst->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memcpy(dst->hdr, src->hdr, ss); + dst->cdr = malloc(GET32(src, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->cdr, src->cdr, GET32(src, hdr->cd_length) * ss); + dst->pdr = malloc(GET32(src, hdr->pdr_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->pdr, src->pdr, GET32(src, hdr->pdr_length) * ss); + dst->vdr = malloc(GET32(src, hdr->vdr_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->vdr, src->vdr, GET32(src, hdr->vdr_length) * ss); + dst->cr = malloc(GET32(src, hdr->cr_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->cr, src->cr, GET32(src, hdr->cr_length) * ss); + dst->pdd = malloc(GET32(src, hdr->pdd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->pdd, src->pdd, GET32(src, hdr->pdd_length) * ss); + if (src->bbm != NULL) { + dst->bbm = malloc(GET32(src, hdr->bbmlog_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->bbm, src->bbm, GET32(src, hdr->bbmlog_length) * ss); + } +} + +static void +ddf_meta_update(struct ddf_meta *meta, struct ddf_meta *src) +{ + struct ddf_pd_entry *pde, *spde; + int i, j; + + for (i = 0; i < GET16(src, pdr->Populated_PDEs); i++) { + spde = &src->pdr->entry[i]; + if (isff(spde->PD_GUID, 24)) + continue; + j = ddf_meta_find_pd(meta, NULL, + src->pdr->entry[i].PD_Reference); + if (j < 0) { + j = ddf_meta_find_pd(meta, NULL, 0xffffffff); + pde = &meta->pdr->entry[j]; + memcpy(pde, spde, sizeof(*pde)); + } else { + pde = &meta->pdr->entry[j]; + SET16D(meta, pde->PD_State, + GET16D(meta, pde->PD_State) | + GET16D(src, pde->PD_State)); + } + } +} + +static void +ddf_meta_free(struct ddf_meta *meta) +{ + + if (meta->hdr != NULL) { + free(meta->hdr, M_MD_DDF); + meta->hdr = NULL; + } + if (meta->cdr != NULL) { + free(meta->cdr, M_MD_DDF); + meta->cdr = NULL; + } + if (meta->pdr != NULL) { + free(meta->pdr, M_MD_DDF); + meta->pdr = NULL; + } + if (meta->vdr != NULL) { + free(meta->vdr, M_MD_DDF); + meta->vdr = NULL; + } + if (meta->cr != NULL) { + free(meta->cr, M_MD_DDF); + meta->cr = NULL; + } + if (meta->pdd != NULL) { + free(meta->pdd, M_MD_DDF); + meta->pdd = NULL; + } + if (meta->bbm != NULL) { + free(meta->bbm, M_MD_DDF); + meta->bbm = NULL; + } +} + +static void +ddf_vol_meta_create(struct ddf_vol_meta *meta, struct ddf_meta *sample) +{ + struct timespec ts; + struct clocktime ct; + struct ddf_header *hdr; + u_int ss, size; + + hdr = sample->hdr; + meta->bigendian = sample->bigendian; + ss = meta->sectorsize = sample->sectorsize; + meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memcpy(meta->hdr, sample->hdr, ss); + meta->cdr = malloc(GET32(sample, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(meta->cdr, sample->cdr, GET32(sample, hdr->cd_length) * ss); + meta->vde = malloc(sizeof(struct ddf_vd_entry), M_MD_DDF, M_WAITOK); + memset(meta->vde, 0xff, sizeof(struct ddf_vd_entry)); + getnanotime(&ts); + clock_ts_to_ct(&ts, &ct); + snprintf(meta->vde->VD_GUID, 25, "FreeBSD%04d%02d%02d%08x%01x", + ct.year, ct.mon, ct.day, + arc4random(), arc4random() & 0xf); + size = GET16(sample, hdr->Configuration_Record_Length) * ss; + meta->vdc = malloc(size, M_MD_DDF, M_WAITOK); + memset(meta->vdc, 0xff, size); + SET32(meta, vdc->Signature, DDF_VDCR_SIGNATURE); + memcpy(meta->vdc->VD_GUID, meta->vde->VD_GUID, 24); + SET32(meta, vdc->Sequence_Number, 0); +} + +static void +ddf_vol_meta_update(struct ddf_vol_meta *dst, struct ddf_meta *src, uint8_t *GUID) +{ + struct ddf_header *hdr; + struct ddf_vd_entry *vde; + struct ddf_vdc_record *vdc; + int vnew, bvnew, bvd, size; + u_int ss; + + hdr = src->hdr; + vde = &src->vdr->entry[ddf_meta_find_vd(src, GUID)]; + vdc = ddf_meta_find_vdc(src, GUID); + bvd = GET8D(src, vdc->Secondary_Element_Seq); + size = GET16(src, hdr->Configuration_Record_Length) * src->sectorsize; + + if (dst->vdc == NULL || + ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, vdc->Sequence_Number))) > 0) + vnew = 1; + else + vnew = 0; + + if (dst->bvdc[bvd] == NULL || + ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, bvdc[bvd]->Sequence_Number))) > 0) + bvnew = 1; + else + bvnew = 0; + + if (vnew) { + dst->bigendian = src->bigendian; + ss = dst->sectorsize = src->sectorsize; + if (dst->hdr != NULL) + free(dst->hdr, M_MD_DDF); + dst->hdr = malloc(ss, M_MD_DDF, M_WAITOK); + memcpy(dst->hdr, src->hdr, ss); + if (dst->cdr != NULL) + free(dst->cdr, M_MD_DDF); + dst->cdr = malloc(GET32(src, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); + memcpy(dst->cdr, src->cdr, GET32(src, hdr->cd_length) * ss); + if (dst->vde != NULL) + free(dst->vde, M_MD_DDF); + dst->vde = malloc(sizeof(struct ddf_vd_entry), M_MD_DDF, M_WAITOK); + memcpy(dst->vde, vde, sizeof(struct ddf_vd_entry)); + if (dst->vdc != NULL) + free(dst->vdc, M_MD_DDF); + dst->vdc = malloc(size, M_MD_DDF, M_WAITOK); + memcpy(dst->vdc, vdc, size); + } + if (bvnew) { + if (dst->bvdc[bvd] != NULL) + free(dst->bvdc[bvd], M_MD_DDF); + dst->bvdc[bvd] = malloc(size, M_MD_DDF, M_WAITOK); + memcpy(dst->bvdc[bvd], vdc, size); + } +} + +static void +ddf_vol_meta_free(struct ddf_vol_meta *meta) +{ + int i; + + if (meta->hdr != NULL) { + free(meta->hdr, M_MD_DDF); + meta->hdr = NULL; + } + if (meta->cdr != NULL) { + free(meta->cdr, M_MD_DDF); + meta->cdr = NULL; + } + if (meta->vde != NULL) { + free(meta->vde, M_MD_DDF); + meta->vde = NULL; + } + if (meta->vdc != NULL) { + free(meta->vdc, M_MD_DDF); + meta->vdc = NULL; + } + for (i = 0; i < DDF_MAX_DISKS_HARD; i++) { + if (meta->bvdc[i] != NULL) { + free(meta->bvdc[i], M_MD_DDF); + meta->bvdc[i] = NULL; + } + } +} + +static int +ddf_meta_unused_range(struct ddf_meta *meta, off_t *off, off_t *size) +{ + struct ddf_vdc_record *vdc; + off_t beg[32], end[32], beg1, end1; + uint64_t *offp; + int i, j, n, num, pos; + uint32_t ref; + + *off = 0; + *size = 0; + ref = GET32(meta, pdd->PD_Reference); + pos = ddf_meta_find_pd(meta, NULL, ref); + beg[0] = 0; + end[0] = GET64(meta, pdr->entry[pos].Configured_Size); + n = 1; + num = GET32(meta, hdr->cr_length) / + GET16(meta, hdr->Configuration_Record_Length); + for (i = 0; i < num; i++) { + vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + + i * GET16(meta, hdr->Configuration_Record_Length) * + meta->sectorsize); + if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) + continue; + for (pos = 0; pos < GET16D(meta, vdc->Primary_Element_Count); pos++) + if (GET32D(meta, vdc->Physical_Disk_Sequence[pos]) == ref) + break; + if (pos == GET16D(meta, vdc->Primary_Element_Count)) + continue; + offp = (uint64_t *)&(vdc->Physical_Disk_Sequence[ + GET16(meta, hdr->Max_Primary_Element_Entries)]); + beg1 = GET64P(meta, offp + pos); + end1 = beg1 + GET64D(meta, vdc->Block_Count); + for (j = 0; j < n; j++) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 21:02:58 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7F93B106564A; Mon, 30 Apr 2012 21:02:58 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3C08FC0A; Mon, 30 Apr 2012 21:02:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UL2wT3085000; Mon, 30 Apr 2012 21:02:58 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UL2wnD084998; Mon, 30 Apr 2012 21:02:58 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201204302102.q3UL2wnD084998@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 30 Apr 2012 21:02:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234850 - head/usr.bin/m4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 21:02:58 -0000 Author: bapt Date: Mon Apr 30 21:02:57 2012 New Revision: 234850 URL: http://svn.freebsd.org/changeset/base/234850 Log: Respect mathematical operation order piority with the exponent gnu extension Obtained from: OpenBSD Approved by: des (mentor) Modified: head/usr.bin/m4/parser.y Modified: head/usr.bin/m4/parser.y ============================================================================== --- head/usr.bin/m4/parser.y Mon Apr 30 17:56:49 2012 (r234849) +++ head/usr.bin/m4/parser.y Mon Apr 30 21:02:57 2012 (r234850) @@ -17,8 +17,8 @@ * * $FreeBSD$ */ -#include #include +#include #define YYSTYPE int32_t extern int32_t end_result; extern int yylex(void); @@ -35,9 +35,9 @@ extern int yyparse(void); %left EQ NE %left '<' LE '>' GE %left LSHIFT RSHIFT -%right EXPONENT %left '+' '-' %left '*' '/' '%' +%right EXPONENT %right UMINUS UPLUS '!' '~' %% From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 21:26:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EDBB106564A; Mon, 30 Apr 2012 21:26:36 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 486CB8FC0C; Mon, 30 Apr 2012 21:26:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3ULQaHf085889; Mon, 30 Apr 2012 21:26:36 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3ULQac3085886; Mon, 30 Apr 2012 21:26:36 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201204302126.q3ULQac3085886@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 30 Apr 2012 21:26:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234851 - in head: libexec/rtld-elf share/man/man5 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 21:26:36 -0000 Author: bapt Date: Mon Apr 30 21:26:35 2012 New Revision: 234851 URL: http://svn.freebsd.org/changeset/base/234851 Log: Add two special directives to libmap.conf: include : Parse the contents of file before continuing with the current file. includedir : Parse the contents of every file in dir that ends in .conf before continuing with the current file. Any file or directory encountered while processing include or includedir directives will be parsed exactly once, even if it is encountered multiple times. Reviewed by: kib, des Approved by: des (mentor) MFC after: 1 month Modified: head/libexec/rtld-elf/libmap.c head/share/man/man5/libmap.conf.5 Modified: head/libexec/rtld-elf/libmap.c ============================================================================== --- head/libexec/rtld-elf/libmap.c Mon Apr 30 21:02:57 2012 (r234850) +++ head/libexec/rtld-elf/libmap.c Mon Apr 30 21:26:35 2012 (r234851) @@ -2,11 +2,13 @@ * $FreeBSD$ */ +#include #include #include #include #include #include +#include #include #include #include @@ -39,9 +41,17 @@ struct lmp { TAILQ_ENTRY(lmp) lmp_link; }; +static TAILQ_HEAD(lmc_list, lmc) lmc_head = TAILQ_HEAD_INITIALIZER(lmc_head); +struct lmc { + char *path; + TAILQ_ENTRY(lmc) next; +}; + static int lm_count; static void lmc_parse(char *, size_t); +static void lmc_parse_file(char *); +static void lmc_parse_dir(char *); static void lm_add(const char *, const char *, const char *); static void lm_free(struct lm_list *); static char *lml_find(struct lm_list *, const char *); @@ -61,37 +71,13 @@ static const char *quickbasename(const c int lm_init(char *libmap_override) { - struct stat st; - char *lm_map, *p; - int fd; + char *p; dbg("lm_init(\"%s\")", libmap_override); TAILQ_INIT(&lmp_head); - fd = open(_PATH_LIBMAP_CONF, O_RDONLY); - if (fd == -1) { - dbg("lm_init: open(\"%s\") failed, %s", _PATH_LIBMAP_CONF, - rtld_strerror(errno)); - goto override; - } - if (fstat(fd, &st) == -1) { - close(fd); - dbg("lm_init: fstat(\"%s\") failed, %s", _PATH_LIBMAP_CONF, - rtld_strerror(errno)); - goto override; - } - lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (lm_map == (const char *)MAP_FAILED) { - close(fd); - dbg("lm_init: mmap(\"%s\") failed, %s", _PATH_LIBMAP_CONF, - rtld_strerror(errno)); - goto override; - } - close(fd); - lmc_parse(lm_map, st.st_size); - munmap(lm_map, st.st_size); + lmc_parse_file(_PATH_LIBMAP_CONF); -override: if (libmap_override) { /* * Do some character replacement to make $LIBMAP look @@ -116,14 +102,116 @@ override: } static void +lmc_parse_file(char *path) +{ + struct lmc *p; + struct stat st; + int fd; + char *rpath; + char *lm_map; + + rpath = realpath(path, NULL); + if (rpath == NULL) + return; + + TAILQ_FOREACH(p, &lmc_head, next) { + if (strcmp(p->path, rpath) == 0) { + free(rpath); + return; + } + } + + fd = open(path, O_RDONLY); + if (fd == -1) { + dbg("lm_init: open(\"%s\") failed, %s", path, + rtld_strerror(errno)); + free(rpath); + return; + } + if (fstat(fd, &st) == -1) { + close(fd); + dbg("lm_init: fstat(\"%s\") failed, %s", path, + rtld_strerror(errno)); + free(rpath); + return; + } + lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (lm_map == (const char *)MAP_FAILED) { + close(fd); + dbg("lm_init: mmap(\"%s\") failed, %s", path, + rtld_strerror(errno)); + free(rpath); + return; + } + close(fd); + p = xmalloc(sizeof(struct lmc)); + p->path = rpath; + TAILQ_INSERT_HEAD(&lmc_head, p, next); + lmc_parse(lm_map, st.st_size); + munmap(lm_map, st.st_size); +} + +static void +lmc_parse_dir(char *idir) +{ + DIR *d; + struct dirent *dp; + struct lmc *p; + char conffile[MAXPATHLEN]; + char *ext; + char *rpath; + + rpath = realpath(idir, NULL); + if (rpath == NULL) + return; + + TAILQ_FOREACH(p, &lmc_head, next) { + if (strcmp(p->path, rpath) == 0) { + free(rpath); + return; + } + } + d = opendir(idir); + if (d == NULL) { + free(rpath); + return; + } + + p = xmalloc(sizeof(struct lmc)); + p->path = rpath; + TAILQ_INSERT_HEAD(&lmc_head, p, next); + + while ((dp = readdir(d)) != NULL) { + if (dp->d_ino == 0) + continue; + if (dp->d_type != DT_REG) + continue; + ext = strrchr(dp->d_name, '.'); + if (ext == NULL) + continue; + if (strcmp(ext, ".conf") != 0) + continue; + if (strlcpy(conffile, idir, MAXPATHLEN) >= MAXPATHLEN) + continue; /* too long */ + if (strlcat(conffile, "/", MAXPATHLEN) >= MAXPATHLEN) + continue; /* too long */ + if (strlcat(conffile, dp->d_name, MAXPATHLEN) >= MAXPATHLEN) + continue; /* too long */ + lmc_parse_file(conffile); + } + closedir(d); +} + +static void lmc_parse(char *lm_p, size_t lm_len) { char *cp, *f, *t, *c, *p; char prog[MAXPATHLEN]; - char line[MAXPATHLEN + 2]; + /* allow includedir + full length path */ + char line[MAXPATHLEN + 13]; size_t cnt; int i; - + cnt = 0; p = NULL; while (cnt < lm_len) { @@ -181,7 +269,8 @@ lmc_parse(char *lm_p, size_t lm_len) while(rtld_isspace(*cp)) cp++; if (!iseol(*cp)) continue; - strcpy(prog, c); + if (strlcpy(prog, c, sizeof prog) >= sizeof prog) + continue; p = prog; continue; } @@ -207,7 +296,12 @@ lmc_parse(char *lm_p, size_t lm_len) if (!iseol(*cp)) continue; *cp = '\0'; - lm_add(p, f, t); + if (strcmp(f, "includedir") == 0) + lmc_parse_dir(t); + else if (strcmp(f, "include") == 0) + lmc_parse_file(t); + else + lm_add(p, f, t); } } @@ -232,9 +326,17 @@ void lm_fini (void) { struct lmp *lmp; + struct lmc *p; dbg("%s()", __func__); + while (!TAILQ_EMPTY(&lmc_head)) { + p = TAILQ_FIRST(&lmc_head); + TAILQ_REMOVE(&lmc_head, p, next); + free(p->path); + free(p); + } + while (!TAILQ_EMPTY(&lmp_head)) { lmp = TAILQ_FIRST(&lmp_head); TAILQ_REMOVE(&lmp_head, lmp, lmp_link); Modified: head/share/man/man5/libmap.conf.5 ============================================================================== --- head/share/man/man5/libmap.conf.5 Mon Apr 30 21:02:57 2012 (r234850) +++ head/share/man/man5/libmap.conf.5 Mon Apr 30 21:26:35 2012 (r234851) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 31, 2004 +.Dd April 28, 2012 .Dt LIBMAP.CONF 5 .Os .Sh NAME @@ -43,6 +43,27 @@ left hand side containing the mapping ca side containing the mapping. Dependencies are matched against candidates and replaced with the mappings. .Pp +Two special directives are available: +.Bl -tag -width indent +.It Cm include Ar file +Parse the contents of +.Ar file +before continuing with the current file. +.It Cm includedir Ar dir +Parse the contents of every file in +.Ar dir +that ends in +.Pa .conf +before continuing with the current file. +.El +.Pp +Any file or directory encountered while processing +.Cm include +or +.Cm includedir +directives will be parsed exactly once, even if it is encountered +multiple times. +.Pp Constrained mappings may be specified by enclosing the name of the executable or library in brackets. All mappings following a constraint will only be evaluated for that constraint. From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 22:00:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EC20E1065676; Mon, 30 Apr 2012 22:00:35 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D5CF98FC15; Mon, 30 Apr 2012 22:00:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UM0Z8l087252; Mon, 30 Apr 2012 22:00:35 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UM0Zwm087217; Mon, 30 Apr 2012 22:00:35 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201204302200.q3UM0Zwm087217@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 30 Apr 2012 22:00:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234852 - head/tools/regression/usr.bin/m4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 22:00:36 -0000 Author: bapt Date: Mon Apr 30 22:00:34 2012 New Revision: 234852 URL: http://svn.freebsd.org/changeset/base/234852 Log: Import m4 regression tests from OpenBSD Obtained from: OpenBSD Approved by: des (mentor) Added: head/tools/regression/usr.bin/m4/args.m4 (contents, props changed) head/tools/regression/usr.bin/m4/args2.m4 (contents, props changed) head/tools/regression/usr.bin/m4/comments.m4 (contents, props changed) head/tools/regression/usr.bin/m4/esyscmd.m4 (contents, props changed) head/tools/regression/usr.bin/m4/eval.m4 (contents, props changed) head/tools/regression/usr.bin/m4/ff_after_dnl.m4.uu (contents, props changed) head/tools/regression/usr.bin/m4/gnueval.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnuformat.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnupatterns.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnupatterns2.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnuprefix.m4 (contents, props changed) head/tools/regression/usr.bin/m4/gnusofterror.m4 (contents, props changed) head/tools/regression/usr.bin/m4/includes.aux (contents, props changed) head/tools/regression/usr.bin/m4/includes.m4 (contents, props changed) head/tools/regression/usr.bin/m4/m4wrap3.m4 (contents, props changed) head/tools/regression/usr.bin/m4/patterns.m4 (contents, props changed) head/tools/regression/usr.bin/m4/quotes.m4 (contents, props changed) head/tools/regression/usr.bin/m4/redef.m4 (contents, props changed) head/tools/regression/usr.bin/m4/regress.args.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.args2.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.comments.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.esyscmd.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.eval.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.ff_after_dnl.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnueval.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnuformat.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnupatterns.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnupatterns2.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnuprefix.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnusofterror.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.gnutranslit2.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.includes.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.m4wrap3.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.patterns.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.quotes.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.redef.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.strangequotes.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.translit.out (contents, props changed) head/tools/regression/usr.bin/m4/regress.translit2.out (contents, props changed) head/tools/regression/usr.bin/m4/strangequotes.m4.uu (contents, props changed) head/tools/regression/usr.bin/m4/translit.m4 (contents, props changed) head/tools/regression/usr.bin/m4/translit2.m4 (contents, props changed) Deleted: head/tools/regression/usr.bin/m4/regress.changecom.in head/tools/regression/usr.bin/m4/regress.changecom.out head/tools/regression/usr.bin/m4/regress.gchangecom.out Modified: head/tools/regression/usr.bin/m4/Makefile head/tools/regression/usr.bin/m4/regress.sh Modified: head/tools/regression/usr.bin/m4/Makefile ============================================================================== --- head/tools/regression/usr.bin/m4/Makefile Mon Apr 30 21:26:35 2012 (r234851) +++ head/tools/regression/usr.bin/m4/Makefile Mon Apr 30 22:00:34 2012 (r234852) @@ -1,4 +1,4 @@ # $FreeBSD$ all: - @sh ${.CURDIR}/regress.sh ${.CURDIR} + @m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR} Added: head/tools/regression/usr.bin/m4/args.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/args.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,9 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/args.m4,v 1.1 2001/10/10 23:23:59 espie Exp $ +dnl Expanding all arguments +define(`A', `first form: $@, second form $*')dnl +define(`B', `C')dnl +A(1,2,`B') +dnl indirection means macro can get called with argc == 2 ! +indir(`A',1,2,`B') +indir(`A') Added: head/tools/regression/usr.bin/m4/args2.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/args2.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,5 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/args2.m4,v 1.1 2008/08/16 09:57:12 espie Exp $ +dnl Preserving spaces within nested parentheses +define(`foo',`$1')dnl +foo(( check for embedded spaces)) Added: head/tools/regression/usr.bin/m4/comments.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/comments.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,59 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/comments.m4,v 1.1 2005/09/06 15:33:21 espie Exp $ +dnl checking the way changecom works. +1: normal +define(`comment', `COMMENT')dnl +define(`p', 'XXX')dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +2: `changecom(>>)dnl' +changecom(>>)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +3: `changecom dnl' +changecom dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +4: `changecom()dnl' +changecom()dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +5: `changecom(,)dnl' +changecom(,)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +6: `changecom(`p',q)dnl' +changecom(`p',q)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +7: `changecom(`p')dnl' +changecom(`p')dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too + +8: `changecom(#)dnl' +changecom(#)dnl +# this is a comment +>> this is a comment +p this is a comment +p this is a comment q comment too Added: head/tools/regression/usr.bin/m4/esyscmd.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/esyscmd.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,43 @@ +dnl $FreeBSD$ +changequote(`{',`}')dnl +dnl +esyscmd({sh -c "m4<>>') +patsubst(`# This is a line to zap +# and a second line +keep this one', `^ *#.* +') +dnl Special case: empty regexp +patsubst(`empty regexp',`',`a ') Added: head/tools/regression/usr.bin/m4/quotes.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/quotes.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,58 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/quotes.m4,v 1.2 2005/09/06 15:33:21 espie Exp $ +dnl Checking the way changequote() is supposed to work +define(`string',`STRING')dnl +1: normal +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +2: kill quotes +changequote()dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +3: normal changed quote +changequote([,])dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +4: empty quotes, kill them too +changequote(,)dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +5: start quote only +changequote(`)dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +6: normal quotes are back +changequote +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' + +7: start quote+empty end quote +changequote([,)dnl +`quoted string' +[quoted string] +normal string +`half quoted string +going up to that string' Added: head/tools/regression/usr.bin/m4/redef.m4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/redef.m4 Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,17 @@ +dnl $FreeBSD$ +dnl $OpenBSD: src/regress/usr.bin/m4/redef.m4,v 1.2 2001/09/27 22:40:58 espie Exp $ +dnl check all properties of builtin are passed on, including args behavior +define(`mybuiltin',defn(`builtin'))dnl +builtin mybuiltin +define(`mydefine',defn(`define'))dnl +mydefine(`mydefn',defn(`defn'))dnl +mydefine(`myundefine',mydefn(`undefine'))dnl +myundefine(`defn')dnl +myundefine(`define')dnl +myundefine(`undefine')dnl +mydefine(`mydef2',mydefn(`mydefine'))dnl +mydefine(`mydef', mydefn(`define'))dnl +myundefine(`mydefine')dnl +mydef2(`A',`B')dnl +mydef(`C',`D')dnl +A C Added: head/tools/regression/usr.bin/m4/regress.args.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.args.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +first form: 1,2,B, second form 1,2,C +first form: 1,2,B, second form 1,2,C +first form: , second form Added: head/tools/regression/usr.bin/m4/regress.args2.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.args2.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1 @@ +( check for embedded spaces) Added: head/tools/regression/usr.bin/m4/regress.comments.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.comments.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,47 @@ +1: normal +# this is a comment +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +2: changecom(>>)dnl +# this is a COMMENT +>> this is a comment +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +3: changecom dnl + # this is a COMMENT +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +4: changecom()dnl +# this is a COMMENT +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +5: changecom(,)dnl +# this is a COMMENT +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too + +6: changecom(`p',q)dnl +# this is a COMMENT +>> this is a COMMENT +p this is a comment +p this is a comment q COMMENT too + +7: changecom(`p')dnl +# this is a COMMENT +>> this is a COMMENT +p this is a comment +p this is a comment q comment too + +8: changecom(#)dnl +# this is a comment +>> this is a COMMENT +'XXX' this is a COMMENT +'XXX' this is a COMMENT q COMMENT too Added: head/tools/regression/usr.bin/m4/regress.esyscmd.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.esyscmd.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,578 @@ + + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + +hi there a +hi there a + + Added: head/tools/regression/usr.bin/m4/regress.eval.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.eval.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +96 +255 +1 Added: head/tools/regression/usr.bin/m4/regress.ff_after_dnl.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.ff_after_dnl.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,2 @@ + THIS SHOULD SHOW UP (LINE 1) + THIS SHOULD SHOW UP (LINE 5) Added: head/tools/regression/usr.bin/m4/regress.gnueval.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnueval.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +65536 +48 +-64 Added: head/tools/regression/usr.bin/m4/regress.gnuformat.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnuformat.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1 @@ +a stringa%bpouet bctoolongcdtoolong2d Added: head/tools/regression/usr.bin/m4/regress.gnupatterns.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnupatterns.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1,3 @@ +string with a minus to replace with a minus +string with b to replbce with b b +minusstring with a starting + to replace with a minus Added: head/tools/regression/usr.bin/m4/regress.gnupatterns2.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/usr.bin/m4/regress.gnupatterns2.out Mon Apr 30 22:00:34 2012 (r234852) @@ -0,0 +1 @@ +acosl asinl atanl cosl sinl tanl coshl sinhl tanhl Added: head/tools/regression/usr.bin/m4/regress.gnuprefix.out ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 22:46:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 415B4106566C; Mon, 30 Apr 2012 22:46:10 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 133658FC08; Mon, 30 Apr 2012 22:46:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UMk9TL089027; Mon, 30 Apr 2012 22:46:09 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UMk9L5089025; Mon, 30 Apr 2012 22:46:09 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201204302246.q3UMk9L5089025@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Mon, 30 Apr 2012 22:46:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234855 - head/contrib/gcc/config/mips X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 22:46:10 -0000 Author: gonzo Date: Mon Apr 30 22:46:09 2012 New Revision: 234855 URL: http://svn.freebsd.org/changeset/base/234855 Log: Unbreak jemalloc build with MALLOC_PRODUCTION set. New jemalloc version uncovered MIPS-related gcc bug described in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33256 The patch was obtained from r128198 in gcc-4_1-branch, which is GPLv2, so it's OK to merge it. Modified: head/contrib/gcc/config/mips/mips.c Modified: head/contrib/gcc/config/mips/mips.c ============================================================================== --- head/contrib/gcc/config/mips/mips.c Mon Apr 30 22:06:47 2012 (r234854) +++ head/contrib/gcc/config/mips/mips.c Mon Apr 30 22:46:09 2012 (r234855) @@ -1297,6 +1297,20 @@ mips_split_const (rtx x, rtx *base, HOST *base = x; } +/* Classify symbolic expression X, given that it appears in context + CONTEXT. */ + +static enum mips_symbol_type +mips_classify_symbolic_expression (rtx x) +{ + HOST_WIDE_INT offset; + + mips_split_const (x, &x, &offset); + if (UNSPEC_ADDRESS_P (x)) + return UNSPEC_ADDRESS_TYPE (x); + + return mips_classify_symbol (x); +} /* Return true if SYMBOL is a SYMBOL_REF and OFFSET + SYMBOL points to the same object as SYMBOL, or to the same object_block. */ @@ -1534,8 +1548,17 @@ mips_classify_address (struct mips_addre info->type = ADDRESS_LO_SUM; info->reg = XEXP (x, 0); info->offset = XEXP (x, 1); + /* We have to trust the creator of the LO_SUM to do something vaguely + sane. Target-independent code that creates a LO_SUM should also + create and verify the matching HIGH. Target-independent code that + adds an offset to a LO_SUM must prove that the offset will not + induce a carry. Failure to do either of these things would be + a bug, and we are not required to check for it here. The MIPS + backend itself should only create LO_SUMs for valid symbolic + constants, with the high part being either a HIGH or a copy + of _gp. */ + info->symbol_type = mips_classify_symbolic_expression (info->offset); return (mips_valid_base_register_p (info->reg, mode, strict) - && mips_symbolic_constant_p (info->offset, &info->symbol_type) && mips_symbolic_address_p (info->symbol_type, mode) && mips_lo_relocs[info->symbol_type] != 0); @@ -5671,7 +5694,8 @@ print_operand_reloc (FILE *file, rtx op, rtx base; HOST_WIDE_INT offset; - if (!mips_symbolic_constant_p (op, &symbol_type) || relocs[symbol_type] == 0) + symbol_type = mips_classify_symbolic_expression (op); + if (relocs[symbol_type] == 0) fatal_insn ("PRINT_OPERAND, invalid operand for relocation", op); /* If OP uses an UNSPEC address, we want to print the inner symbol. */ From owner-svn-src-head@FreeBSD.ORG Mon Apr 30 23:12:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1B93106564A; Mon, 30 Apr 2012 23:12:16 +0000 (UTC) (envelope-from rmh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D0758FC15; Mon, 30 Apr 2012 23:12:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3UNCGQd089974; Mon, 30 Apr 2012 23:12:16 GMT (envelope-from rmh@svn.freebsd.org) Received: (from rmh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3UNCG8p089972; Mon, 30 Apr 2012 23:12:16 GMT (envelope-from rmh@svn.freebsd.org) Message-Id: <201204302312.q3UNCG8p089972@svn.freebsd.org> From: Robert Millan Date: Mon, 30 Apr 2012 23:12:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234856 - head/cddl/compat/opensolaris/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2012 23:12:16 -0000 Author: rmh Date: Mon Apr 30 23:12:16 2012 New Revision: 234856 URL: http://svn.freebsd.org/changeset/base/234856 Log: GNU/kFreeBSD portability fix. This glue overrides header protection in the system-wide version of by wrapping the #include_next within the scope of its own header protection. On FreeBSD this has no effect, since both header protections are equivalent. However the GNU version of implements a special header protection mechanism which allows it to be included multiple times (in different modes). Simply by moving the #include_next off the header protection, we allow system-wide to implement its own protection policy, whichever that may be. Modified: head/cddl/compat/opensolaris/include/stdlib.h Modified: head/cddl/compat/opensolaris/include/stdlib.h ============================================================================== --- head/cddl/compat/opensolaris/include/stdlib.h Mon Apr 30 22:46:09 2012 (r234855) +++ head/cddl/compat/opensolaris/include/stdlib.h Mon Apr 30 23:12:16 2012 (r234856) @@ -27,11 +27,11 @@ * */ +#include_next + #ifndef _COMPAT_OPENSOLARIS_STDLIB_H_ #define _COMPAT_OPENSOLARIS_STDLIB_H_ -#include_next - #define getexecname getprogname #endif From owner-svn-src-head@FreeBSD.ORG Tue May 1 01:19:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6A2A106566B; Tue, 1 May 2012 01:19:56 +0000 (UTC) (envelope-from jwd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2CD18FC08; Tue, 1 May 2012 01:19:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q411JuRA094603; Tue, 1 May 2012 01:19:56 GMT (envelope-from jwd@svn.freebsd.org) Received: (from jwd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q411JuVC094601; Tue, 1 May 2012 01:19:56 GMT (envelope-from jwd@svn.freebsd.org) Message-Id: <201205010119.q411JuVC094601@svn.freebsd.org> From: "John W. De Boskey" Date: Tue, 1 May 2012 01:19:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234857 - head/share/misc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 01:19:56 -0000 Author: jwd Date: Tue May 1 01:19:56 2012 New Revision: 234857 URL: http://svn.freebsd.org/changeset/base/234857 Log: Add myself to this file - it didn't exist last time. Approved by: rmacklem (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot ============================================================================== --- head/share/misc/committers-src.dot Mon Apr 30 23:12:16 2012 (r234856) +++ head/share/misc/committers-src.dot Tue May 1 01:19:56 2012 (r234857) @@ -177,6 +177,7 @@ jon [label="Jonathan Chen\njon@FreeBSD.o jonathan [label="Jonathan Anderson\njonathan@FreeBSD.org\n2010/10/07"] jpaetzel [label="Josh Paetzel\njpaetzel@FreeBSD.org\n2011/01/21"] julian [label="Julian Elischer\njulian@FreeBSD.org\n1993/??/??"] +jwd [label="John De Boskey\njwd@FreeBSD.org\n2000/05/19"] kaiw [label="Kai Wang\nkaiw@FreeBSD.org\n2007/09/26"] kan [label="Alexander Kabaev\nkan@FreeBSD.org\n2002/07/21"] kargl [label="Steven G. Kargl\nkargl@FreeBSD.org\n2011/01/17"] @@ -438,6 +439,7 @@ jhb -> rnoland jkh -> imp jkh -> jlemon jkh -> joerg +jkh -> jwd jkh -> phk jkh -> wes jkh -> yar @@ -541,6 +543,8 @@ pjd -> trociny rgrimes -> markm +rmacklem -> jwd + rpaulo -> avg rpaulo -> bschmidt rpaulo -> dim From owner-svn-src-head@FreeBSD.ORG Tue May 1 04:35:54 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CE12106566B; Tue, 1 May 2012 04:35:54 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EBE858FC08; Tue, 1 May 2012 04:35:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q414ZrYB001847; Tue, 1 May 2012 04:35:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q414Zr6H001844; Tue, 1 May 2012 04:35:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010435.q414Zr6H001844@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 04:35:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234859 - in head/sys: conf mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 04:35:54 -0000 Author: adrian Date: Tue May 1 04:35:53 2012 New Revision: 234859 URL: http://svn.freebsd.org/changeset/base/234859 Log: Migrate ARGE_DEBUG to opt_arge.h. Submitted by: Stefan Bethke Modified: head/sys/conf/options.mips head/sys/mips/atheros/if_arge.c Modified: head/sys/conf/options.mips ============================================================================== --- head/sys/conf/options.mips Tue May 1 04:01:22 2012 (r234858) +++ head/sys/conf/options.mips Tue May 1 04:35:53 2012 (r234859) @@ -65,7 +65,7 @@ OCTEON_BOARD_CAPK_0100ND opt_cvmx.h # # Options that control the Atheros SoC peripherals # -ARGE_DEBUG opt_global.h +ARGE_DEBUG opt_arge.h # # Options that control the Ralink RT305xF Etherenet MAC. Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Tue May 1 04:01:22 2012 (r234858) +++ head/sys/mips/atheros/if_arge.c Tue May 1 04:35:53 2012 (r234859) @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); #include "opt_device_polling.h" #endif +#include "opt_arge.h" + #include #include #include From owner-svn-src-head@FreeBSD.ORG Tue May 1 05:05:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9438710682B3; Tue, 1 May 2012 05:04:50 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B5EB8FC1A; Tue, 1 May 2012 05:04:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4154o2b002890; Tue, 1 May 2012 05:04:50 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4154niY002886; Tue, 1 May 2012 05:04:50 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201205010504.q4154niY002886@svn.freebsd.org> From: Tim Kientzle Date: Tue, 1 May 2012 05:04:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234860 - head/sys/boot/uboot/lib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 05:05:09 -0000 Author: kientzle Date: Tue May 1 05:04:49 2012 New Revision: 234860 URL: http://svn.freebsd.org/changeset/base/234860 Log: Teach ubldr(8) about simple MBR partitioning. Modified: head/sys/boot/uboot/lib/devicename.c head/sys/boot/uboot/lib/disk.c head/sys/boot/uboot/lib/libuboot.h Modified: head/sys/boot/uboot/lib/devicename.c ============================================================================== --- head/sys/boot/uboot/lib/devicename.c Tue May 1 04:35:53 2012 (r234859) +++ head/sys/boot/uboot/lib/devicename.c Tue May 1 05:04:49 2012 (r234860) @@ -131,6 +131,10 @@ uboot_parsedev(struct uboot_devdesc **de *(cp + 1) != ':') { pnum = strtol(cp + 1, &cp, 10); ptype = PTYPE_GPT; + } else if (*cp == 's' && *(cp + 1) && + *(cp + 1) != ':') { + pnum = strtol(cp + 1, &cp, 10); + ptype = PTYPE_MBR; } else { pnum = *cp - 'a'; ptype = PTYPE_BSDLABEL; @@ -218,6 +222,9 @@ uboot_fmtdev(void *vdev) else if (dev->d_kind.disk.ptype == PTYPE_GPT) cp += sprintf(cp, "p%i", dev->d_kind.disk.pnum); + else if (dev->d_kind.disk.ptype == PTYPE_MBR) + cp += sprintf(cp, "s%i", + dev->d_kind.disk.pnum); } strcat(cp, ":"); Modified: head/sys/boot/uboot/lib/disk.c ============================================================================== --- head/sys/boot/uboot/lib/disk.c Tue May 1 04:35:53 2012 (r234859) +++ head/sys/boot/uboot/lib/disk.c Tue May 1 05:04:49 2012 (r234860) @@ -398,6 +398,94 @@ out: } static int +stor_open_mbr(struct open_dev *od, struct uboot_devdesc *dev) +{ + char *buf = NULL; + struct dos_partition *dp; + int err, i, part; + + od->od_nparts = 0; + od->od_partitions = NULL; + + /* Block size must be at least 512 bytes. */ + if (od->od_bsize < 512) + return (ENXIO); + + /* Read MBR */ + buf = malloc(od->od_bsize); + if (!buf) { + stor_printf("could not allocate memory for MBR\n"); + return (ENOMEM); + } + err = stor_readdev(dev, 0, 1, buf); + if (err) { + stor_printf("MBR read error=%d\n", err); + err = EIO; + goto out; + } + + /* Check the slice table magic. */ + if (le16toh(*((uint16_t *)(buf + DOSMAGICOFFSET))) != DOSMAGIC) { + err = ENXIO; + goto out; + } + + /* Save information about partitions. */ + dp = (struct dos_partition *)(buf + DOSPARTOFF); + od->od_partitions = calloc(NDOSPART, sizeof(struct gpt_part)); + if (!od->od_partitions) { + stor_printf("could not allocate memory for MBR partitions\n"); + err = ENOMEM; + goto out; + } + + part = 0; + for (i = 0; i < NDOSPART; i++) { + u_int32_t start = le32dec(&dp[i].dp_start); + u_int32_t size = le32dec(&dp[i].dp_size); + uuid_t *u = NULL; + + /* Map MBR partition types to GPT partition types. */ + switch (dp[i].dp_typ) { + case DOSPTYP_386BSD: + u = &freebsd_ufs; + break; + /* XXX Other types XXX */ + } + + if (u) { + od->od_partitions[part].gp_type = *u; + od->od_partitions[part].gp_index = i + 1; + od->od_partitions[part].gp_start = start; + od->od_partitions[part].gp_end = start + size; + part += 1; + } + } + od->od_nparts = part; + + if (od->od_nparts == 0) { + err = EINVAL; + goto out; + } + + dev->d_disk.ptype = PTYPE_MBR; + + /* XXX Be smarter here? XXX */ + if (dev->d_disk.pnum == 0) + dev->d_disk.pnum = od->od_partitions[0].gp_index; + + for (i = 0; i < od->od_nparts; i++) + if (od->od_partitions[i].gp_index == dev->d_disk.pnum) + od->od_bstart = od->od_partitions[i].gp_start; + +out: + if (err && od->od_partitions) + free(od->od_partitions); + free(buf); + return (err); +} + +static int stor_open_bsdlabel(struct open_dev *od, struct uboot_devdesc *dev) { char *buf; @@ -443,7 +531,7 @@ stor_readdev(struct uboot_devdesc *dev, lbasize_t real_size; int err, handle; - debugf("reading size=%d @ 0x%08x\n", size, (uint32_t)buf); + debugf("reading blk=%d size=%d @ 0x%08x\n", (int)blk, size, (uint32_t)buf); handle = stor_info[dev->d_unit]; err = ub_dev_read(handle, buf, size, blk, &real_size); @@ -495,7 +583,10 @@ stor_opendev(struct open_dev **odp, stru od->od_bsize = di->di_stor.block_size; od->od_bstart = 0; - if ((err = stor_open_gpt(od, dev)) != 0) + err = stor_open_gpt(od, dev); + if (err != 0) + err = stor_open_mbr(od, dev); + if (err != 0) err = stor_open_bsdlabel(od, dev); if (err != 0) @@ -517,6 +608,8 @@ stor_closedev(struct uboot_devdesc *dev) od = (struct open_dev *)dev->d_disk.data; if (dev->d_disk.ptype == PTYPE_GPT && od->od_nparts != 0) free(od->od_partitions); + if (dev->d_disk.ptype == PTYPE_MBR && od->od_nparts != 0) + free(od->od_partitions); free(od); dev->d_disk.data = NULL; Modified: head/sys/boot/uboot/lib/libuboot.h ============================================================================== --- head/sys/boot/uboot/lib/libuboot.h Tue May 1 04:35:53 2012 (r234859) +++ head/sys/boot/uboot/lib/libuboot.h Tue May 1 05:04:49 2012 (r234860) @@ -45,6 +45,7 @@ struct uboot_devdesc #define PTYPE_BSDLABEL 1 #define PTYPE_GPT 2 +#define PTYPE_MBR 3 /* * Default network packet alignment in memory From owner-svn-src-head@FreeBSD.ORG Tue May 1 06:11:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A4D51065670; Tue, 1 May 2012 06:11:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E80F78FC19; Tue, 1 May 2012 06:11:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q416BcBc005219; Tue, 1 May 2012 06:11:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q416BcYW005211; Tue, 1 May 2012 06:11:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010611.q416BcYW005211@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 06:11:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234861 - in head/sys: conf dev/etherswitch X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 06:11:39 -0000 Author: adrian Date: Tue May 1 06:11:38 2012 New Revision: 234861 URL: http://svn.freebsd.org/changeset/base/234861 Log: Bring over the first part of the etherswitch framework - an MDIO bus and MDIO/MII rendezvous proxy. * Add an 'mdio' bus, which is the "IO" side of an MII bus (but by design can be anything which implements the underlying register access API.) * Add 'miiproxy' and 'mdioproxy', which provides a rendezvous mechanism for MII busses to appear hanging off arbitrary busses (ie, that aren't necessarily a traditional looking MII bus.) MII busses can now hang off anything that implements an mdiobus. For the AR71xx SoC, there's one MDIO bus but two MII busses. So to properly support two or more real PHYs, this can be done: # arge0 MDIO bus - there's no arge1 MDIO bus for AR71xx hint.argemdio.0.at="nexus0" hint.argemdio.0.maddr=0x19000000 hint.argemdio.0.msize=0x1000 hint.argemdio.0.order=0 # Create two mdioproxy instances hint.mdioproxy.0.at="mdio0" hint.mdioproxy.1.at="mdio0" # .. and with a follow-up patch hint.arge.0.mdio=mdioproxy0 hint.arge.1.mdio=mdioproxy0 TODO: * Do a sweep or two and add appropriate locking in mdio/mdioproxy/miiproxy. Submitted by: Stefan Bethke Reviewed by: ray Added: head/sys/dev/etherswitch/ head/sys/dev/etherswitch/mdio.c (contents, props changed) head/sys/dev/etherswitch/mdio.h (contents, props changed) head/sys/dev/etherswitch/mdio_if.m (contents, props changed) head/sys/dev/etherswitch/miiproxy.c (contents, props changed) head/sys/dev/etherswitch/miiproxy.h (contents, props changed) Modified: head/sys/conf/files head/sys/conf/kmod.mk Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue May 1 05:04:49 2012 (r234860) +++ head/sys/conf/files Tue May 1 06:11:38 2012 (r234861) @@ -3683,3 +3683,7 @@ dev/xen/netback/netback.c optional xen | dev/xen/netfront/netfront.c optional xen | xenhvm dev/xen/xenpci/xenpci.c optional xenpci dev/xen/xenpci/evtchn.c optional xenpci + +dev/etherswitch/mdio_if.m optional miiproxy +dev/etherswitch/mdio.c optional miiproxy +dev/etherswitch/miiproxy.c optional miiproxy Modified: head/sys/conf/kmod.mk ============================================================================== --- head/sys/conf/kmod.mk Tue May 1 05:04:49 2012 (r234860) +++ head/sys/conf/kmod.mk Tue May 1 06:11:38 2012 (r234861) @@ -354,7 +354,7 @@ MFILES?= dev/acpica/acpi_if.m dev/acpi_s kern/bus_if.m kern/clock_if.m \ kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \ libkern/iconv_converter_if.m opencrypto/cryptodev_if.m \ - pc98/pc98/canbus_if.m + pc98/pc98/canbus_if.m dev/etherswitch/mdio_if.m .for _srcsrc in ${MFILES} .for _ext in c h Added: head/sys/dev/etherswitch/mdio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/mdio.c Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,117 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS 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$ + */ + +#include +#include +#include + +#include + +#include "mdio_if.h" + +static void +mdio_identify(driver_t *driver, device_t parent) +{ + + if (device_find_child(parent, mdio_driver.name, -1) == NULL) + BUS_ADD_CHILD(parent, 0, mdio_driver.name, -1); +} + +static int +mdio_probe(device_t dev) +{ + + device_set_desc(dev, "MDIO"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +mdio_attach(device_t dev) +{ + + bus_generic_probe(dev); + bus_enumerate_hinted_children(dev); + return (bus_generic_attach(dev)); +} + +static int +mdio_detach(device_t dev) +{ + + bus_generic_detach(dev); + return (0); +} + +static int +mdio_readreg(device_t dev, int phy, int reg) +{ + + return (MDIO_READREG(device_get_parent(dev), phy, reg)); +} + +static int +mdio_writereg(device_t dev, int phy, int reg, int val) +{ + + return (MDIO_WRITEREG(device_get_parent(dev), phy, reg, val)); +} + +static void +mdio_hinted_child(device_t dev, const char *name, int unit) +{ + + device_add_child(dev, name, unit); +} + +static device_method_t mdio_methods[] = { + /* device interface */ + DEVMETHOD(device_identify, mdio_identify), + DEVMETHOD(device_probe, mdio_probe), + DEVMETHOD(device_attach, mdio_attach), + DEVMETHOD(device_detach, mdio_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* bus interface */ + DEVMETHOD(bus_add_child, device_add_child_ordered), + DEVMETHOD(bus_hinted_child, mdio_hinted_child), + + /* MDIO access */ + DEVMETHOD(mdio_readreg, mdio_readreg), + DEVMETHOD(mdio_writereg, mdio_writereg), + + DEVMETHOD_END +}; + +driver_t mdio_driver = { + "mdio", + mdio_methods, + 0 +}; + +devclass_t mdio_devclass; Added: head/sys/dev/etherswitch/mdio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/mdio.h Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS 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$ + */ + +#ifndef __DEV_ETHERSWITCH_MDIO_H__ +#define __DEV_ETHERSWITCH_MDIO_H__ + +extern driver_t mdio_driver; +extern devclass_t mdio_devclass; + +#endif /* __DEV_ETHERSWITCH_MDIO_H__ */ Added: head/sys/dev/etherswitch/mdio_if.m ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/mdio_if.m Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,24 @@ +# $FreeBSD$ + +#include + +INTERFACE mdio; + +# +# Read register from device on MDIO bus +# +METHOD int readreg { + device_t dev; + int phy; + int reg; +}; + +# +# Write register to device on MDIO bus +# +METHOD int writereg { + device_t dev; + int phy; + int reg; + int val; +}; Added: head/sys/dev/etherswitch/miiproxy.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/miiproxy.c Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,444 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS 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$ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "mdio_if.h" +#include "miibus_if.h" + + +MALLOC_DECLARE(M_MIIPROXY); +MALLOC_DEFINE(M_MIIPROXY, "miiproxy", "miiproxy data structures"); + +driver_t miiproxy_driver; +driver_t mdioproxy_driver; + +struct miiproxy_softc { + device_t parent; + device_t proxy; + device_t mdio; +}; + +struct mdioproxy_softc { +}; + +/* + * The rendevous data structures and functions allow two device endpoints to + * match up, so that the proxy endpoint can be associated with a target + * endpoint. The proxy has to know the device name of the target that it + * wants to associate with, for example through a hint. The rendevous code + * makes no assumptions about the devices that want to meet. + */ +struct rendevous_entry; + +enum rendevous_op { + RENDEVOUS_ATTACH, + RENDEVOUS_DETACH +}; + +typedef int (*rendevous_callback_t)(enum rendevous_op, + struct rendevous_entry *); + +static SLIST_HEAD(rendevoushead, rendevous_entry) rendevoushead = + SLIST_HEAD_INITIALIZER(rendevoushead); + +struct rendevous_endpoint { + device_t device; + const char *name; + rendevous_callback_t callback; +}; + +struct rendevous_entry { + SLIST_ENTRY(rendevous_entry) entries; + struct rendevous_endpoint proxy; + struct rendevous_endpoint target; +}; + +/* + * Call the callback routines for both the proxy and the target. If either + * returns an error, undo the attachment. + */ +static int +rendevous_attach(struct rendevous_entry *e, struct rendevous_endpoint *ep) +{ + int error; + + error = e->proxy.callback(RENDEVOUS_ATTACH, e); + if (error == 0) { + error = e->target.callback(RENDEVOUS_ATTACH, e); + if (error != 0) { + e->proxy.callback(RENDEVOUS_DETACH, e); + ep->device = NULL; + ep->callback = NULL; + } + } + return (error); +} + +/* + * Create an entry for the proxy in the rendevous list. The name parameter + * indicates the name of the device that is the target endpoint for this + * rendevous. The callback will be invoked as soon as the target is + * registered: either immediately if the target registered itself earlier, + * or once the target registers. Returns ENXIO if the target has not yet + * registered. + */ +static int +rendevous_register_proxy(device_t dev, const char *name, + rendevous_callback_t callback) +{ + struct rendevous_entry *e; + + KASSERT(callback != NULL, ("callback must be set")); + SLIST_FOREACH(e, &rendevoushead, entries) { + if (strcmp(name, e->target.name) == 0) { + /* the target is already attached */ + e->proxy.name = device_get_nameunit(dev); + e->proxy.device = dev; + e->proxy.callback = callback; + return (rendevous_attach(e, &e->proxy)); + } + } + e = malloc(sizeof(*e), M_MIIPROXY, M_WAITOK | M_ZERO); + e->proxy.name = device_get_nameunit(dev); + e->proxy.device = dev; + e->proxy.callback = callback; + e->target.name = name; + SLIST_INSERT_HEAD(&rendevoushead, e, entries); + return (ENXIO); +} + +/* + * Create an entry in the rendevous list for the target. + * Returns ENXIO if the proxy has not yet registered. + */ +static int +rendevous_register_target(device_t dev, rendevous_callback_t callback) +{ + struct rendevous_entry *e; + const char *name; + + KASSERT(callback != NULL, ("callback must be set")); + name = device_get_nameunit(dev); + SLIST_FOREACH(e, &rendevoushead, entries) { + if (strcmp(name, e->target.name) == 0) { + e->target.device = dev; + e->target.callback = callback; + return (rendevous_attach(e, &e->target)); + } + } + e = malloc(sizeof(*e), M_MIIPROXY, M_WAITOK | M_ZERO); + e->target.name = name; + e->target.device = dev; + e->target.callback = callback; + SLIST_INSERT_HEAD(&rendevoushead, e, entries); + return (ENXIO); +} + +/* + * Remove the registration for the proxy. + */ +static int +rendevous_unregister_proxy(device_t dev) +{ + struct rendevous_entry *e; + int error = 0; + + SLIST_FOREACH(e, &rendevoushead, entries) { + if (e->proxy.device == dev) { + if (e->target.device == NULL) { + SLIST_REMOVE(&rendevoushead, e, rendevous_entry, entries); + free(e, M_MIIPROXY); + return (0); + } else { + e->proxy.callback(RENDEVOUS_DETACH, e); + e->target.callback(RENDEVOUS_DETACH, e); + } + e->proxy.device = NULL; + e->proxy.callback = NULL; + return (error); + } + } + return (ENOENT); +} + +/* + * Remove the registration for the target. + */ +static int +rendevous_unregister_target(device_t dev) +{ + struct rendevous_entry *e; + int error = 0; + + SLIST_FOREACH(e, &rendevoushead, entries) { + if (e->target.device == dev) { + if (e->proxy.device == NULL) { + SLIST_REMOVE(&rendevoushead, e, rendevous_entry, entries); + free(e, M_MIIPROXY); + return (0); + } else { + e->proxy.callback(RENDEVOUS_DETACH, e); + e->target.callback(RENDEVOUS_DETACH, e); + } + e->target.device = NULL; + e->target.callback = NULL; + return (error); + } + } + return (ENOENT); +} + +/* + * Functions of the proxy that is interposed between the ethernet interface + * driver and the miibus device. + */ + +static int +miiproxy_rendevous_callback(enum rendevous_op op, struct rendevous_entry *rendevous) +{ + struct miiproxy_softc *sc = device_get_softc(rendevous->proxy.device); + + switch (op) { + case RENDEVOUS_ATTACH: + sc->mdio = device_get_parent(rendevous->target.device); + break; + case RENDEVOUS_DETACH: + sc->mdio = NULL; + break; + } + return (0); +} + +static int +miiproxy_probe(device_t dev) +{ + device_set_desc(dev, "MII/MDIO proxy, MII side"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +miiproxy_attach(device_t dev) +{ + + /* + * The ethernet interface needs to call mii_attach_proxy() to pass + * the relevant parameters for rendevous with the MDIO target. + */ + return (bus_generic_attach(dev)); +} + +static int +miiproxy_detach(device_t dev) +{ + + rendevous_unregister_proxy(dev); + bus_generic_detach(dev); + return (0); +} + +static int +miiproxy_readreg(device_t dev, int phy, int reg) +{ + struct miiproxy_softc *sc = device_get_softc(dev); + + if (sc->mdio != NULL) + return (MDIO_READREG(sc->mdio, phy, reg)); + return (-1); +} + +static int +miiproxy_writereg(device_t dev, int phy, int reg, int val) +{ + struct miiproxy_softc *sc = device_get_softc(dev); + + if (sc->mdio != NULL) + return (MDIO_WRITEREG(sc->mdio, phy, reg, val)); + return (-1); +} + +static void +miiproxy_statchg(device_t dev) +{ + + MIIBUS_STATCHG(device_get_parent(dev)); +} + +static void +miiproxy_linkchg(device_t dev) +{ + + MIIBUS_LINKCHG(device_get_parent(dev)); +} + +static void +miiproxy_mediainit(device_t dev) +{ + + MIIBUS_MEDIAINIT(device_get_parent(dev)); +} + +/* + * Functions for the MDIO target device driver. + */ +static int +mdioproxy_rendevous_callback(enum rendevous_op op, struct rendevous_entry *rendevous) +{ + return (0); +} + +static void +mdioproxy_identify(driver_t *driver, device_t parent) +{ + device_t child; + + if (device_find_child(parent, driver->name, -1) == NULL) { + child = BUS_ADD_CHILD(parent, 0, driver->name, -1); + } +} + +static int +mdioproxy_probe(device_t dev) +{ + device_set_desc(dev, "MII/MDIO proxy, MDIO side"); + + return (BUS_PROBE_SPECIFIC); +} + +static int +mdioproxy_attach(device_t dev) +{ + + rendevous_register_target(dev, mdioproxy_rendevous_callback); + return (bus_generic_attach(dev)); +} + +static int +mdioproxy_detach(device_t dev) +{ + + rendevous_unregister_target(dev); + bus_generic_detach(dev); + return (0); +} + +/* + * Attach this proxy in place of miibus. The target MDIO must be attached + * already. Returns NULL on error. + */ +device_t +mii_attach_proxy(device_t dev) +{ + struct miiproxy_softc *sc; + int error; + const char *name; + device_t miiproxy; + + if (resource_string_value(device_get_name(dev), + device_get_unit(dev), "mdio", &name) != 0) { + if (bootverbose) + printf("mii_attach_proxy: not attaching, no mdio" + " device hint for %s\n", device_get_nameunit(dev)); + return (NULL); + } + + miiproxy = device_add_child(dev, miiproxy_driver.name, -1); + error = bus_generic_attach(dev); + if (error != 0) { + device_printf(dev, "can't attach miiproxy\n"); + return (NULL); + } + sc = device_get_softc(miiproxy); + sc->parent = dev; + sc->proxy = miiproxy; + if (rendevous_register_proxy(miiproxy, name, miiproxy_rendevous_callback) != 0) { + device_printf(dev, "can't attach proxy\n"); + return (NULL); + } + device_printf(miiproxy, "attached to target %s\n", device_get_nameunit(sc->mdio)); + return (miiproxy); +} + +static device_method_t miiproxy_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, miiproxy_probe), + DEVMETHOD(device_attach, miiproxy_attach), + DEVMETHOD(device_detach, miiproxy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + /* MII interface */ + DEVMETHOD(miibus_readreg, miiproxy_readreg), + DEVMETHOD(miibus_writereg, miiproxy_writereg), + DEVMETHOD(miibus_statchg, miiproxy_statchg), + DEVMETHOD(miibus_linkchg, miiproxy_linkchg), + DEVMETHOD(miibus_mediainit, miiproxy_mediainit), + + DEVMETHOD_END +}; + +static device_method_t mdioproxy_methods[] = { + /* device interface */ + DEVMETHOD(device_identify, mdioproxy_identify), + DEVMETHOD(device_probe, mdioproxy_probe), + DEVMETHOD(device_attach, mdioproxy_attach), + DEVMETHOD(device_detach, mdioproxy_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + DEVMETHOD_END +}; + +DEFINE_CLASS_0(miiproxy, miiproxy_driver, miiproxy_methods, + sizeof(struct miiproxy_softc)); +DEFINE_CLASS_0(mdioproxy, mdioproxy_driver, mdioproxy_methods, + sizeof(struct mdioproxy_softc)); + +devclass_t miiproxy_devclass; +static devclass_t mdioproxy_devclass; + +DRIVER_MODULE(mdioproxy, mdio, mdioproxy_driver, mdioproxy_devclass, 0, 0); +DRIVER_MODULE(miibus, miiproxy, miibus_driver, miibus_devclass, 0, 0); +MODULE_VERSION(miiproxy, 1); +MODULE_DEPEND(miiproxy, miibus, 1, 1, 1); Added: head/sys/dev/etherswitch/miiproxy.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/etherswitch/miiproxy.h Tue May 1 06:11:38 2012 (r234861) @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2011-2012 Stefan Bethke. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS 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$ + */ + +#ifndef __DEV_ETHERSWITCH_MIIPROXY_H__ +#define __DEV_ETHERSWITCH_MIIPROXY_H__ + +extern devclass_t miiproxy_devclass; +extern driver_t miiproxy_driver; + +device_t mii_attach_proxy(device_t dev); + +#endif /* __DEV_ETHERSWITCH_MIIPROXY_H__ */ From owner-svn-src-head@FreeBSD.ORG Tue May 1 06:18:30 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2A711065673; Tue, 1 May 2012 06:18:30 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C7078FC18; Tue, 1 May 2012 06:18:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q416IUNl005486; Tue, 1 May 2012 06:18:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q416IU9V005481; Tue, 1 May 2012 06:18:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010618.q416IU9V005481@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 06:18:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234862 - in head/sys: conf mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 06:18:30 -0000 Author: adrian Date: Tue May 1 06:18:30 2012 New Revision: 234862 URL: http://svn.freebsd.org/changeset/base/234862 Log: Break out the arge MDIO bus code into an optional argemdio device. This is only done if the ARGE_MDIO option is included. * Shuffle the arge MDIO bus into a separate device, that needs to be probed early (use hint.argemdio.X.order=0) * hint.arge.X.mdio now specifies which miiproxy to rendezvous with. * Call MAC/MDIO bus init during MDIO attach, not arge attach. This is done regardless: * Shift the arge MAC and MDIO bus reset code into separate functions and call it early during MDIO bus attach. It's required for correct MDIO bus IO to occur on AR71xx/AR91xx devices. * Remove the AR71xx/AR91xx centric assumption that there's only one MDIO bus. The initial code mapped miibus0(arge0) and miibus1(arge1) MII register operations to the MII0 (arge0) register space. The AR724x (and later, upcoming chipsets) have two MDIO busses and the second is very much in use. TODO: * since the multiphy behaviour has changed (where now a phymask of >1 PHY will still be enumerated), multiphy setups may be quite wrong. I'll go and fix these so they still have a chance of working, at least. until the switch PHY support appears in -HEAD. Submitted by: Stefan Bethke Modified: head/sys/conf/options.mips head/sys/mips/atheros/ar71xxreg.h head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/conf/options.mips ============================================================================== --- head/sys/conf/options.mips Tue May 1 06:11:38 2012 (r234861) +++ head/sys/conf/options.mips Tue May 1 06:18:30 2012 (r234862) @@ -66,6 +66,7 @@ OCTEON_BOARD_CAPK_0100ND opt_cvmx.h # Options that control the Atheros SoC peripherals # ARGE_DEBUG opt_arge.h +ARGE_MDIO opt_arge.h # # Options that control the Ralink RT305xF Etherenet MAC. Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Tue May 1 06:11:38 2012 (r234861) +++ head/sys/mips/atheros/ar71xxreg.h Tue May 1 06:18:30 2012 (r234862) @@ -283,10 +283,6 @@ */ #define AR71XX_MAC0_BASE 0x19000000 #define AR71XX_MAC1_BASE 0x1A000000 -/* - * All 5 PHYs accessible only through MAC0 register space - */ -#define AR71XX_MII_BASE 0x19000000 #define AR71XX_MAC_CFG1 0x00 #define MAC_CFG1_SOFT_RESET (1 << 31) Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Tue May 1 06:11:38 2012 (r234861) +++ head/sys/mips/atheros/if_arge.c Tue May 1 06:18:30 2012 (r234862) @@ -74,8 +74,18 @@ __FBSDID("$FreeBSD$"); #include #include +#include "opt_arge.h" + +#if defined(ARGE_MDIO) +#include +#include +#include "mdio_if.h" +#endif + + MODULE_DEPEND(arge, ether, 1, 1, 1); MODULE_DEPEND(arge, miibus, 1, 1, 1); +MODULE_VERSION(arge, 1); #include "miibus_if.h" @@ -138,6 +148,8 @@ static void arge_intr(void *); static int arge_intr_filter(void *); static void arge_tick(void *); +static void arge_hinted_child(device_t bus, const char *dname, int dunit); + /* * ifmedia callbacks for multiPHY MAC */ @@ -164,6 +176,10 @@ static device_method_t arge_methods[] = DEVMETHOD(miibus_writereg, arge_miibus_writereg), DEVMETHOD(miibus_statchg, arge_miibus_statchg), + /* bus interface */ + DEVMETHOD(bus_add_child, device_add_child_ordered), + DEVMETHOD(bus_hinted_child, arge_hinted_child), + DEVMETHOD_END }; @@ -178,6 +194,37 @@ static devclass_t arge_devclass; DRIVER_MODULE(arge, nexus, arge_driver, arge_devclass, 0, 0); DRIVER_MODULE(miibus, arge, miibus_driver, miibus_devclass, 0, 0); +#if defined(ARGE_MDIO) +static int argemdio_probe(device_t); +static int argemdio_attach(device_t); +static int argemdio_detach(device_t); + +/* + * Declare an additional, separate driver for accessing the MDIO bus. + */ +static device_method_t argemdio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, argemdio_probe), + DEVMETHOD(device_attach, argemdio_attach), + DEVMETHOD(device_detach, argemdio_detach), + + /* bus interface */ + DEVMETHOD(bus_add_child, device_add_child_ordered), + + /* MDIO access */ + DEVMETHOD(mdio_readreg, arge_miibus_readreg), + DEVMETHOD(mdio_writereg, arge_miibus_writereg), +}; + +DEFINE_CLASS_0(argemdio, argemdio_driver, argemdio_methods, + sizeof(struct arge_softc)); +static devclass_t argemdio_devclass; + +DRIVER_MODULE(miiproxy, arge, miiproxy_driver, miiproxy_devclass, 0, 0); +DRIVER_MODULE(argemdio, nexus, argemdio_driver, argemdio_devclass, 0, 0); +DRIVER_MODULE(mdio, argemdio, mdio_driver, mdio_devclass, 0, 0); +#endif + /* * RedBoot passes MAC address to entry point as environment * variable. platfrom_start parses it and stores in this variable @@ -237,15 +284,53 @@ arge_attach_sysctl(device_t dev) #endif } +static void +arge_reset_mac(struct arge_softc *sc) +{ + uint32_t reg; + + /* Step 1. Soft-reset MAC */ + ARGE_SET_BITS(sc, AR71XX_MAC_CFG1, MAC_CFG1_SOFT_RESET); + DELAY(20); + + /* Step 2. Punt the MAC core from the central reset register */ + ar71xx_device_stop(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : + RST_RESET_GE1_MAC); + DELAY(100); + ar71xx_device_start(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : + RST_RESET_GE1_MAC); + + /* Step 3. Reconfigure MAC block */ + ARGE_WRITE(sc, AR71XX_MAC_CFG1, + MAC_CFG1_SYNC_RX | MAC_CFG1_RX_ENABLE | + MAC_CFG1_SYNC_TX | MAC_CFG1_TX_ENABLE); + + reg = ARGE_READ(sc, AR71XX_MAC_CFG2); + reg |= MAC_CFG2_ENABLE_PADCRC | MAC_CFG2_LENGTH_FIELD ; + ARGE_WRITE(sc, AR71XX_MAC_CFG2, reg); + + ARGE_WRITE(sc, AR71XX_MAC_MAX_FRAME_LEN, 1536); +} + +static void +arge_reset_miibus(struct arge_softc *sc) +{ + + /* Reset MII bus */ + ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_RESET); + DELAY(100); + ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_CLOCK_DIV_28); + DELAY(100); +} + static int arge_attach(device_t dev) { - uint8_t eaddr[ETHER_ADDR_LEN]; struct ifnet *ifp; struct arge_softc *sc; - int error = 0, rid, phymask; - uint32_t reg, rnd; - int is_base_mac_empty, i, phys_total; + int error = 0, rid; + uint32_t rnd; + int is_base_mac_empty, i; uint32_t hint; long eeprom_mac_addr = 0; @@ -280,20 +365,19 @@ arge_attach(device_t dev) /* * Get which PHY of 5 available we should use for this unit */ - if (resource_int_value(device_get_name(dev), device_get_unit(dev), - "phymask", &phymask) != 0) { + if (resource_int_value(device_get_name(dev), device_get_unit(dev), + "phymask", &sc->arge_phymask) != 0) { /* * Use port 4 (WAN) for GE0. For any other port use * its PHY the same as its unit number */ if (sc->arge_mac_unit == 0) - phymask = (1 << 4); + sc->arge_phymask = (1 << 4); else /* Use all phys up to 4 */ - phymask = (1 << 4) - 1; + sc->arge_phymask = (1 << 4) - 1; - device_printf(dev, "No PHY specified, using mask %d\n", - phymask); + device_printf(dev, "No PHY specified, using mask %d\n", sc->arge_phymask); } /* @@ -318,8 +402,6 @@ arge_attach(device_t dev) else sc->arge_duplex_mode = 0; - sc->arge_phymask = phymask; - mtx_init(&sc->arge_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); callout_init_mtx(&sc->arge_stat_callout, &sc->arge_mtx, 0); @@ -327,8 +409,8 @@ arge_attach(device_t dev) /* Map control/status registers. */ sc->arge_rid = 0; - sc->arge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &sc->arge_rid, RF_ACTIVE); + sc->arge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->arge_rid, RF_ACTIVE | RF_SHAREABLE); if (sc->arge_res == NULL) { device_printf(dev, "couldn't map memory\n"); @@ -376,8 +458,8 @@ arge_attach(device_t dev) is_base_mac_empty = 1; for (i = 0; i < ETHER_ADDR_LEN; i++) { - eaddr[i] = ar711_base_mac[i] & 0xff; - if (eaddr[i] != 0) + sc->arge_eaddr[i] = ar711_base_mac[i] & 0xff; + if (sc->arge_eaddr[i] != 0) is_base_mac_empty = 0; } @@ -390,59 +472,40 @@ arge_attach(device_t dev) "Generating random ethernet address.\n"); rnd = arc4random(); - eaddr[0] = 'b'; - eaddr[1] = 's'; - eaddr[2] = 'd'; - eaddr[3] = (rnd >> 24) & 0xff; - eaddr[4] = (rnd >> 16) & 0xff; - eaddr[5] = (rnd >> 8) & 0xff; + sc->arge_eaddr[0] = 'b'; + sc->arge_eaddr[1] = 's'; + sc->arge_eaddr[2] = 'd'; + sc->arge_eaddr[3] = (rnd >> 24) & 0xff; + sc->arge_eaddr[4] = (rnd >> 16) & 0xff; + sc->arge_eaddr[5] = (rnd >> 8) & 0xff; } - if (sc->arge_mac_unit != 0) - eaddr[5] += sc->arge_mac_unit; + sc->arge_eaddr[5] += sc->arge_mac_unit; if (arge_dma_alloc(sc) != 0) { error = ENXIO; goto fail; } + /* + * Don't do this for the MDIO bus case - it's already done + * as part of the MDIO bus attachment. + */ +#if !defined(ARGE_MDIO) /* Initialize the MAC block */ - - /* Step 1. Soft-reset MAC */ - ARGE_SET_BITS(sc, AR71XX_MAC_CFG1, MAC_CFG1_SOFT_RESET); - DELAY(20); - - /* Step 2. Punt the MAC core from the central reset register */ - ar71xx_device_stop(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : - RST_RESET_GE1_MAC); - DELAY(100); - ar71xx_device_start(sc->arge_mac_unit == 0 ? RST_RESET_GE0_MAC : - RST_RESET_GE1_MAC); - - /* Step 3. Reconfigure MAC block */ - ARGE_WRITE(sc, AR71XX_MAC_CFG1, - MAC_CFG1_SYNC_RX | MAC_CFG1_RX_ENABLE | - MAC_CFG1_SYNC_TX | MAC_CFG1_TX_ENABLE); - - reg = ARGE_READ(sc, AR71XX_MAC_CFG2); - reg |= MAC_CFG2_ENABLE_PADCRC | MAC_CFG2_LENGTH_FIELD ; - ARGE_WRITE(sc, AR71XX_MAC_CFG2, reg); - - ARGE_WRITE(sc, AR71XX_MAC_MAX_FRAME_LEN, 1536); - - /* Reset MII bus */ - ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_RESET); - DELAY(100); - ARGE_WRITE(sc, AR71XX_MAC_MII_CFG, MAC_MII_CFG_CLOCK_DIV_28); - DELAY(100); + arge_reset_mac(sc); + arge_reset_miibus(sc); +#endif /* * Set all Ethernet address registers to the same initial values * set all four addresses to 66-88-aa-cc-dd-ee */ - ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR1, - (eaddr[2] << 24) | (eaddr[3] << 16) | (eaddr[4] << 8) | eaddr[5]); - ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR2, (eaddr[0] << 8) | eaddr[1]); + ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR1, (sc->arge_eaddr[2] << 24) + | (sc->arge_eaddr[3] << 16) | (sc->arge_eaddr[4] << 8) + | sc->arge_eaddr[5]); + ARGE_WRITE(sc, AR71XX_MAC_STA_ADDR2, (sc->arge_eaddr[0] << 8) + | sc->arge_eaddr[1]); ARGE_WRITE(sc, AR71XX_MAC_FIFO_CFG0, FIFO_CFG0_ALL << FIFO_CFG0_ENABLE_SHIFT); @@ -465,31 +528,30 @@ arge_attach(device_t dev) ARGE_WRITE(sc, AR71XX_MAC_FIFO_RX_FILTMASK, FIFO_RX_FILTMASK_DEFAULT); - /* - * Check if we have single-PHY MAC or multi-PHY - */ - phys_total = 0; - for (i = 0; i < ARGE_NPHY; i++) - if (phymask & (1 << i)) - phys_total ++; - - if (phys_total == 0) { - error = EINVAL; - goto fail; - } +#if defined(ARGE_MDIO) + sc->arge_miiproxy = mii_attach_proxy(sc->arge_dev); +#endif - if (phys_total == 1) { - /* Do MII setup. */ - error = mii_attach(dev, &sc->arge_miibus, ifp, - arge_ifmedia_upd, arge_ifmedia_sts, BMSR_DEFCAPMASK, - MII_PHY_ANY, MII_OFFSET_ANY, 0); - if (error != 0) { - device_printf(dev, "attaching PHYs failed\n"); - goto fail; + device_printf(sc->arge_dev, "finishing attachment, phymask %04x" + ", proxy %s \n", sc->arge_phymask, sc->arge_miiproxy == NULL ? + "null" : "set"); + for (i = 0; i < ARGE_NPHY; i++) { + if (((1 << i) & sc->arge_phymask) != 0) { + error = mii_attach(sc->arge_miiproxy != NULL ? + sc->arge_miiproxy : sc->arge_dev, + &sc->arge_miibus, sc->arge_ifp, + arge_ifmedia_upd, arge_ifmedia_sts, + BMSR_DEFCAPMASK, i, MII_OFFSET_ANY, 0); + if (error != 0) { + device_printf(sc->arge_dev, "unable to attach" + " PHY %d: %d\n", i, error); + goto fail; + } } } - else { - ifmedia_init(&sc->arge_ifmedia, 0, + if (sc->arge_miibus == NULL) { + /* no PHY, so use hard-coded values */ + ifmedia_init(&sc->arge_ifmedia, 0, arge_multiphy_mediachange, arge_multiphy_mediastatus); ifmedia_add(&sc->arge_ifmedia, @@ -501,23 +563,23 @@ arge_attach(device_t dev) } /* Call MI attach routine. */ - ether_ifattach(ifp, eaddr); + ether_ifattach(sc->arge_ifp, sc->arge_eaddr); /* Hook interrupt last to avoid having to lock softc */ - error = bus_setup_intr(dev, sc->arge_irq, INTR_TYPE_NET | INTR_MPSAFE, + error = bus_setup_intr(sc->arge_dev, sc->arge_irq, INTR_TYPE_NET | INTR_MPSAFE, arge_intr_filter, arge_intr, sc, &sc->arge_intrhand); if (error) { - device_printf(dev, "couldn't set up irq\n"); - ether_ifdetach(ifp); + device_printf(sc->arge_dev, "couldn't set up irq\n"); + ether_ifdetach(sc->arge_ifp); goto fail; } /* setup sysctl variables */ - arge_attach_sysctl(dev); + arge_attach_sysctl(sc->arge_dev); fail: - if (error) + if (error) arge_detach(dev); return (error); @@ -550,6 +612,9 @@ arge_detach(device_t dev) if (sc->arge_miibus) device_delete_child(dev, sc->arge_miibus); + if (sc->arge_miiproxy) + device_delete_child(dev, sc->arge_miiproxy); + bus_generic_detach(dev); if (sc->arge_intrhand) @@ -600,6 +665,13 @@ arge_shutdown(device_t dev) return (0); } +static void +arge_hinted_child(device_t bus, const char *dname, int dunit) +{ + BUS_ADD_CHILD(bus, 0, dname, dunit); + device_printf(bus, "hinted child %s%d\n", dname, dunit); +} + static int arge_miibus_readreg(device_t dev, int phy, int reg) { @@ -608,16 +680,13 @@ arge_miibus_readreg(device_t dev, int ph uint32_t addr = (phy << MAC_MII_PHY_ADDR_SHIFT) | (reg & MAC_MII_REG_MASK); - if ((sc->arge_phymask & (1 << phy)) == 0) - return (0); - mtx_lock(&miibus_mtx); - ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); - ARGE_MII_WRITE(AR71XX_MAC_MII_ADDR, addr); - ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_READ); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_ADDR, addr); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CMD, MAC_MII_CMD_READ); i = ARGE_MII_TIMEOUT; - while ((ARGE_MII_READ(AR71XX_MAC_MII_INDICATOR) & + while ((ARGE_MDIO_READ(sc, AR71XX_MAC_MII_INDICATOR) & MAC_MII_INDICATOR_BUSY) && (i--)) DELAY(5); @@ -628,8 +697,8 @@ arge_miibus_readreg(device_t dev, int ph return (-1); } - result = ARGE_MII_READ(AR71XX_MAC_MII_STATUS) & MAC_MII_STATUS_MASK; - ARGE_MII_WRITE(AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); + result = ARGE_MDIO_READ(sc, AR71XX_MAC_MII_STATUS) & MAC_MII_STATUS_MASK; + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CMD, MAC_MII_CMD_WRITE); mtx_unlock(&miibus_mtx); ARGEDEBUG(sc, ARGE_DBG_MII, @@ -647,19 +716,15 @@ arge_miibus_writereg(device_t dev, int p uint32_t addr = (phy << MAC_MII_PHY_ADDR_SHIFT) | (reg & MAC_MII_REG_MASK); - - if ((sc->arge_phymask & (1 << phy)) == 0) - return (-1); - - ARGEDEBUG(sc, ARGE_DBG_MII, "%s: phy=%d, reg=%02x, value=%04x\n", - __func__, phy, reg, data); + ARGEDEBUG(sc, ARGE_DBG_MII, "%s: phy=%d, reg=%02x, value=%04x\n", __func__, + phy, reg, data); mtx_lock(&miibus_mtx); - ARGE_MII_WRITE(AR71XX_MAC_MII_ADDR, addr); - ARGE_MII_WRITE(AR71XX_MAC_MII_CONTROL, data); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_ADDR, addr); + ARGE_MDIO_WRITE(sc, AR71XX_MAC_MII_CONTROL, data); i = ARGE_MII_TIMEOUT; - while ((ARGE_MII_READ(AR71XX_MAC_MII_INDICATOR) & + while ((ARGE_MDIO_READ(sc, AR71XX_MAC_MII_INDICATOR) & MAC_MII_INDICATOR_BUSY) && (i--)) DELAY(5); @@ -729,6 +794,8 @@ arge_set_pll(struct arge_softc *sc, int uint32_t fifo_tx; int if_speed; + ARGEDEBUG(sc, ARGE_DBG_MII, "set_pll(%04x, %s)\n", media, + duplex == IFM_FDX ? "full" : "half"); cfg = ARGE_READ(sc, AR71XX_MAC_CFG2); cfg &= ~(MAC_CFG2_IFACE_MODE_1000 | MAC_CFG2_IFACE_MODE_10_100 @@ -1992,3 +2059,48 @@ arge_multiphy_mediastatus(struct ifnet * sc->arge_duplex_mode; } +#if defined(ARGE_MDIO) +static int +argemdio_probe(device_t dev) +{ + device_set_desc(dev, "Atheros AR71xx built-in ethernet interface, MDIO controller"); + return (0); +} + +static int +argemdio_attach(device_t dev) +{ + struct arge_softc *sc; + int error = 0; + + sc = device_get_softc(dev); + sc->arge_dev = dev; + sc->arge_mac_unit = device_get_unit(dev); + sc->arge_rid = 0; + sc->arge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->arge_rid, RF_ACTIVE | RF_SHAREABLE); + if (sc->arge_res == NULL) { + device_printf(dev, "couldn't map memory\n"); + error = ENXIO; + goto fail; + } + + /* Reset MAC - required for AR71xx MDIO to successfully occur */ + arge_reset_mac(sc); + /* Reset MII bus */ + arge_reset_miibus(sc); + + bus_generic_probe(dev); + bus_enumerate_hinted_children(dev); + error = bus_generic_attach(dev); +fail: + return (error); +} + +static int +argemdio_detach(device_t dev) +{ + return (0); +} + +#endif Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Tue May 1 06:11:38 2012 (r234861) +++ head/sys/mips/atheros/if_argevar.h Tue May 1 06:18:30 2012 (r234862) @@ -67,15 +67,10 @@ #define ARGE_CLEAR_BITS(sc, reg, bits) \ ARGE_WRITE(sc, reg, ARGE_READ(sc, (reg)) & ~(bits)) -/* - * MII registers access macros - */ -#define ARGE_MII_READ(reg) \ - *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1((AR71XX_MII_BASE + reg))) - -#define ARGE_MII_WRITE(reg, val) \ - *((volatile uint32_t *)MIPS_PHYS_TO_KSEG1((AR71XX_MII_BASE + reg))) = (val) - +#define ARGE_MDIO_WRITE(_sc, _reg, _val) \ + ARGE_WRITE((_sc), (_reg), (_val)) +#define ARGE_MDIO_READ(_sc, _reg) \ + ARGE_READ((_sc), (_reg)) #define ARGE_DESC_EMPTY (1 << 31) #define ARGE_DESC_MORE (1 << 24) @@ -132,11 +127,14 @@ struct arge_softc { */ uint32_t arge_media_type; uint32_t arge_duplex_mode; + uint32_t arge_phymask; + uint8_t arge_eaddr[ETHER_ADDR_LEN]; struct resource *arge_res; int arge_rid; struct resource *arge_irq; void *arge_intrhand; device_t arge_miibus; + device_t arge_miiproxy; bus_dma_tag_t arge_parent_tag; bus_dma_tag_t arge_tag; struct mtx arge_mtx; @@ -148,7 +146,6 @@ struct arge_softc { int arge_detach; uint32_t arge_intr_status; int arge_mac_unit; - int arge_phymask; int arge_if_flags; uint32_t arge_debug; struct { From owner-svn-src-head@FreeBSD.ORG Tue May 1 06:21:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43960106564A; Tue, 1 May 2012 06:21:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFADC8FC0C; Tue, 1 May 2012 06:21:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q416L2Jw005604; Tue, 1 May 2012 06:21:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q416L20c005601; Tue, 1 May 2012 06:21:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205010621.q416L20c005601@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 06:21:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234863 - head/sys/mips/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 06:21:03 -0000 Author: adrian Date: Tue May 1 06:21:02 2012 New Revision: 234863 URL: http://svn.freebsd.org/changeset/base/234863 Log: Convert AP96 to use the mdioproxy and ARGE_MDIO option. arge1 still works (it's the standalone PHY) but arge0 and the other switch ports don't work. They're enumerated though, demonstrating that the mdiobus abstraction is correctly working. Modified: head/sys/mips/conf/AP96 head/sys/mips/conf/AP96.hints Modified: head/sys/mips/conf/AP96 ============================================================================== --- head/sys/mips/conf/AP96 Tue May 1 06:18:30 2012 (r234862) +++ head/sys/mips/conf/AP96 Tue May 1 06:21:02 2012 (r234863) @@ -40,3 +40,7 @@ options ROOTDEVNAME=\"ufs:map/ro options AR71XX_ATH_EEPROM # Fetch EEPROM/PCI config from flash options ATH_EEPROM_FIRMWARE # Use EEPROM from flash device firmware # Used by the above + +# Options required for miiproxy and mdiobus +options ARGE_MDIO # Export an MDIO bus separate from arge +device miiproxy # MDIO bus <-> MII PHY rendezvous Modified: head/sys/mips/conf/AP96.hints ============================================================================== --- head/sys/mips/conf/AP96.hints Tue May 1 06:18:30 2012 (r234862) +++ head/sys/mips/conf/AP96.hints Tue May 1 06:21:02 2012 (r234863) @@ -1,15 +1,33 @@ # $FreeBSD$ +# arge0 MDIO bus - there's no arge1 MDIO bus for AR71xx +hint.argemdio.0.at="nexus0" +hint.argemdio.0.maddr=0x19000000 +hint.argemdio.0.msize=0x1000 +hint.argemdio.0.order=0 + +# Create two mdioproxy instances - by default only one is created +# per mdiobus above. +hint.mdioproxy.0.at="mdio0" +hint.mdioproxy.1.at="mdio0" + # TODO: RGMII +# XXX this port currently doesn't work with the current configuration. hint.arge.0.phymask=0x0f hint.arge.0.media=1000 hint.arge.0.fduplex=1 +# For now, rendezouvs this on the arge0 mdiobus. +# Later, this will rendezvous via the AR8316 switch. +hint.arge.0.mdio=mdioproxy0 # TODO: RGMII # TODO: pll_1000 = 0x1f000000 hint.arge.1.phymask=0x10 # hint.arge.1.media=1000 # hint.arge.1.fduplex=1 +# For now, rendezouvs this on the arge0 mdiobus. +# Later, this will rendezvous via the AR8316 switch. +hint.arge.1.mdio=mdioproxy1 # ath0 - slot 17 hint.pcib.0.bus.0.17.0.ath_fixup_addr=0x1fff1000 From owner-svn-src-head@FreeBSD.ORG Tue May 1 07:38:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D8024106566B; Tue, 1 May 2012 07:38:40 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C33368FC14; Tue, 1 May 2012 07:38:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q417ce2S008433; Tue, 1 May 2012 07:38:40 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q417cewW008431; Tue, 1 May 2012 07:38:40 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201205010738.q417cewW008431@svn.freebsd.org> From: Ulrich Spoerlein Date: Tue, 1 May 2012 07:38:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234866 - head/sys/modules/mwl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 07:38:40 -0000 Author: uqs Date: Tue May 1 07:38:40 2012 New Revision: 234866 URL: http://svn.freebsd.org/changeset/base/234866 Log: Fix make depend. Modified: head/sys/modules/mwl/Makefile Modified: head/sys/modules/mwl/Makefile ============================================================================== --- head/sys/modules/mwl/Makefile Tue May 1 07:27:23 2012 (r234865) +++ head/sys/modules/mwl/Makefile Tue May 1 07:38:40 2012 (r234866) @@ -33,7 +33,7 @@ KMOD= if_mwl SRCS= if_mwl.c if_mwl_pci.c mwlhal.c -SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_mwl.h +SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_mwl.h opt_wlan.h opt_mwl.h: echo '#define MWL_DEBUG 1'> $@ From owner-svn-src-head@FreeBSD.ORG Tue May 1 07:46:30 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D8A6A1065675; Tue, 1 May 2012 07:46:30 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2D498FC08; Tue, 1 May 2012 07:46:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q417kU5N008752; Tue, 1 May 2012 07:46:30 GMT (envelope-from daichi@svn.freebsd.org) Received: (from daichi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q417kUSs008748; Tue, 1 May 2012 07:46:30 GMT (envelope-from daichi@svn.freebsd.org) Message-Id: <201205010746.q417kUSs008748@svn.freebsd.org> From: Daichi GOTO Date: Tue, 1 May 2012 07:46:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234867 - head/sys/fs/unionfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 07:46:30 -0000 Author: daichi Date: Tue May 1 07:46:30 2012 New Revision: 234867 URL: http://svn.freebsd.org/changeset/base/234867 Log: - fixed a vnode lock hang-up issue. - fixed an incorrect lock status issue. - fixed an incorrect lock issue of unionfs root vnode removed. (pointed out by keith) - fixed an infinity loop issue. (pointed out by dumbbell) - changed to do LK_RELEASE expressly when unlocked. Submitted by: ozawa@ongs.co.jp Modified: head/sys/fs/unionfs/union_subr.c head/sys/fs/unionfs/union_vfsops.c head/sys/fs/unionfs/union_vnops.c Modified: head/sys/fs/unionfs/union_subr.c ============================================================================== --- head/sys/fs/unionfs/union_subr.c Tue May 1 07:38:40 2012 (r234866) +++ head/sys/fs/unionfs/union_subr.c Tue May 1 07:46:30 2012 (r234867) @@ -2,8 +2,8 @@ * Copyright (c) 1994 Jan-Simon Pendry * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. - * Copyright (c) 2005, 2006 Masanori Ozawa , ONGS Inc. - * Copyright (c) 2006 Daichi Goto + * Copyright (c) 2005, 2006, 2012 Masanori Ozawa , ONGS Inc. + * Copyright (c) 2006, 2012 Daichi Goto * * This code is derived from software contributed to Berkeley by * Jan-Simon Pendry. @@ -350,19 +350,22 @@ unionfs_noderem(struct vnode *vp, struct uvp = unp->un_uppervp; dvp = unp->un_dvp; unp->un_lowervp = unp->un_uppervp = NULLVP; - vp->v_vnlock = &(vp->v_lock); vp->v_data = NULL; - lockmgr(vp->v_vnlock, LK_EXCLUSIVE | LK_INTERLOCK, VI_MTX(vp)); + vp->v_object = NULL; + VI_UNLOCK(vp); + if (lvp != NULLVP) - VOP_UNLOCK(lvp, 0); + VOP_UNLOCK(lvp, LK_RELEASE); if (uvp != NULLVP) - VOP_UNLOCK(uvp, 0); - vp->v_object = NULL; + VOP_UNLOCK(uvp, LK_RELEASE); if (dvp != NULLVP && unp->un_hash.le_prev != NULL) unionfs_rem_cached_vnode(unp, dvp); + if (lockmgr(vp->v_vnlock, LK_EXCLUSIVE, VI_MTX(vp)) != 0) + panic("the lock for deletion is unacquirable."); + if (lvp != NULLVP) { vfslocked = VFS_LOCK_GIANT(lvp->v_mount); vrele(lvp); @@ -550,7 +553,7 @@ unionfs_relookup(struct vnode *dvp, stru cn->cn_flags |= (cnp->cn_flags & SAVESTART); vref(dvp); - VOP_UNLOCK(dvp, 0); + VOP_UNLOCK(dvp, LK_RELEASE); if ((error = relookup(dvp, vpp, cn))) { uma_zfree(namei_zone, cn->cn_pnbuf); @@ -957,7 +960,7 @@ unionfs_vn_create_on_upper(struct vnode *vpp = vp; unionfs_vn_create_on_upper_free_out1: - VOP_UNLOCK(udvp, 0); + VOP_UNLOCK(udvp, LK_RELEASE); unionfs_vn_create_on_upper_free_out2: if (cn.cn_flags & HASBUF) { Modified: head/sys/fs/unionfs/union_vfsops.c ============================================================================== --- head/sys/fs/unionfs/union_vfsops.c Tue May 1 07:38:40 2012 (r234866) +++ head/sys/fs/unionfs/union_vfsops.c Tue May 1 07:46:30 2012 (r234867) @@ -1,8 +1,8 @@ /*- * Copyright (c) 1994, 1995 The Regents of the University of California. * Copyright (c) 1994, 1995 Jan-Simon Pendry. - * Copyright (c) 2005, 2006 Masanori Ozawa , ONGS Inc. - * Copyright (c) 2006 Daichi Goto + * Copyright (c) 2005, 2006, 2012 Masanori Ozawa , ONGS Inc. + * Copyright (c) 2006, 2012 Daichi Goto * All rights reserved. * * This code is derived from software donated to Berkeley by @@ -165,7 +165,7 @@ unionfs_domount(struct mount *mp) uid = va.va_uid; gid = va.va_gid; } - VOP_UNLOCK(mp->mnt_vnodecovered, 0); + VOP_UNLOCK(mp->mnt_vnodecovered, LK_RELEASE); if (error) return (error); @@ -250,7 +250,7 @@ unionfs_domount(struct mount *mp) * Save reference */ if (below) { - VOP_UNLOCK(upperrootvp, 0); + VOP_UNLOCK(upperrootvp, LK_RELEASE); vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY); ump->um_lowervp = upperrootvp; ump->um_uppervp = lowerrootvp; @@ -281,7 +281,7 @@ unionfs_domount(struct mount *mp) /* * Unlock the node */ - VOP_UNLOCK(ump->um_uppervp, 0); + VOP_UNLOCK(ump->um_uppervp, LK_RELEASE); /* * Get the unionfs root vnode. Modified: head/sys/fs/unionfs/union_vnops.c ============================================================================== --- head/sys/fs/unionfs/union_vnops.c Tue May 1 07:38:40 2012 (r234866) +++ head/sys/fs/unionfs/union_vnops.c Tue May 1 07:46:30 2012 (r234867) @@ -2,8 +2,8 @@ * Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry. * Copyright (c) 1992, 1993, 1994, 1995 * The Regents of the University of California. - * Copyright (c) 2005, 2006 Masanori Ozawa , ONGS Inc. - * Copyright (c) 2006 Daichi Goto + * Copyright (c) 2005, 2006, 2012 Masanori Ozawa , ONGS Inc. + * Copyright (c) 2006, 2012 Daichi Goto * All rights reserved. * * This code is derived from software contributed to Berkeley by @@ -75,21 +75,6 @@ KASSERT(((vp)->v_op == &unionfs_vnodeops), \ ("unionfs: it is not unionfs-vnode")) -/* lockmgr lock <-> reverse table */ -struct lk_lr_table { - int lock; - int revlock; -}; - -static struct lk_lr_table un_llt[] = { - {LK_SHARED, LK_RELEASE}, - {LK_EXCLUSIVE, LK_RELEASE}, - {LK_UPGRADE, LK_DOWNGRADE}, - {LK_DOWNGRADE, LK_UPGRADE}, - {0, 0} -}; - - static int unionfs_lookup(struct vop_cachedlookup_args *ap) { @@ -141,7 +126,7 @@ unionfs_lookup(struct vop_cachedlookup_a if (udvp != NULLVP) { dtmpvp = udvp; if (ldvp != NULLVP) - VOP_UNLOCK(ldvp, 0); + VOP_UNLOCK(ldvp, LK_RELEASE); } else dtmpvp = ldvp; @@ -149,7 +134,7 @@ unionfs_lookup(struct vop_cachedlookup_a error = VOP_LOOKUP(dtmpvp, &vp, cnp); if (dtmpvp == udvp && ldvp != NULLVP) { - VOP_UNLOCK(udvp, 0); + VOP_UNLOCK(udvp, LK_RELEASE); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); } @@ -161,10 +146,10 @@ unionfs_lookup(struct vop_cachedlookup_a */ if (nameiop == DELETE || nameiop == RENAME || (cnp->cn_lkflags & LK_TYPE_MASK)) - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); vrele(vp); - VOP_UNLOCK(dvp, 0); + VOP_UNLOCK(dvp, LK_RELEASE); *(ap->a_vpp) = dunp->un_dvp; vref(dunp->un_dvp); @@ -202,7 +187,7 @@ unionfs_lookup(struct vop_cachedlookup_a } if (nameiop == DELETE || nameiop == RENAME || (cnp->cn_lkflags & LK_TYPE_MASK)) - VOP_UNLOCK(uvp, 0); + VOP_UNLOCK(uvp, LK_RELEASE); } /* check whiteout */ @@ -246,7 +231,7 @@ unionfs_lookup(struct vop_cachedlookup_a return (lerror); } if (cnp->cn_lkflags & LK_TYPE_MASK) - VOP_UNLOCK(lvp, 0); + VOP_UNLOCK(lvp, LK_RELEASE); } } @@ -281,7 +266,7 @@ unionfs_lookup(struct vop_cachedlookup_a goto unionfs_lookup_out; if (LK_SHARED == (cnp->cn_lkflags & LK_TYPE_MASK)) - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); if (LK_EXCLUSIVE != VOP_ISLOCKED(vp)) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); lockflag = 1; @@ -289,7 +274,7 @@ unionfs_lookup(struct vop_cachedlookup_a error = unionfs_mkshadowdir(MOUNTTOUNIONFSMOUNT(dvp->v_mount), udvp, VTOUNIONFS(vp), cnp, td); if (lockflag != 0) - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); if (error != 0) { UNIONFSDEBUG("unionfs_lookup: Unable to create shadow dir."); if ((cnp->cn_lkflags & LK_TYPE_MASK) == LK_EXCLUSIVE) @@ -386,7 +371,7 @@ unionfs_create(struct vop_create_args *a if (vp->v_type == VSOCK) *(ap->a_vpp) = vp; else { - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, curthread); vrele(vp); @@ -460,7 +445,7 @@ unionfs_mknod(struct vop_mknod_args *ap) if (vp->v_type == VSOCK) *(ap->a_vpp) = vp; else { - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, curthread); vrele(vp); @@ -564,6 +549,7 @@ unionfs_close(struct vop_close_args *ap) struct unionfs_node_status *unsp; struct ucred *cred; struct thread *td; + struct vnode *vp; struct vnode *ovp; UNIONFS_INTERNAL_DEBUG("unionfs_close: enter\n"); @@ -571,12 +557,14 @@ unionfs_close(struct vop_close_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); locked = 0; - unp = VTOUNIONFS(ap->a_vp); + vp = ap->a_vp; + unp = VTOUNIONFS(vp); cred = ap->a_cred; td = ap->a_td; - if (VOP_ISLOCKED(ap->a_vp) != LK_EXCLUSIVE) { - vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY); + if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) { + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); locked = 1; } unionfs_get_node_status(unp, td, &unsp); @@ -599,7 +587,7 @@ unionfs_close(struct vop_close_args *ap) if (error != 0) goto unionfs_close_abort; - ap->a_vp->v_object = ovp->v_object; + vp->v_object = ovp->v_object; if (ovp == unp->un_uppervp) { unsp->uns_upper_opencnt--; @@ -610,7 +598,7 @@ unionfs_close(struct vop_close_args *ap) unsp->uns_lower_opencnt--; } if (unsp->uns_lower_opencnt > 0) - ap->a_vp->v_object = unp->un_lowervp->v_object; + vp->v_object = unp->un_lowervp->v_object; } } else unsp->uns_lower_opencnt--; @@ -619,7 +607,7 @@ unionfs_close_abort: unionfs_tryrem_node_status(unp, unsp); if (locked != 0) - VOP_UNLOCK(ap->a_vp, 0); + vn_lock(vp, LK_DOWNGRADE | LK_RETRY); UNIONFS_INTERNAL_DEBUG("unionfs_close: leave (%d)\n", error); @@ -914,7 +902,7 @@ unionfs_ioctl(struct vop_ioctl_args *ap) unionfs_get_node_status(unp, ap->a_td, &unsp); ovp = (unsp->uns_upper_opencnt ? unp->un_uppervp : unp->un_lowervp); unionfs_tryrem_node_status(unp, unsp); - VOP_UNLOCK(ap->a_vp, 0); + VOP_UNLOCK(ap->a_vp, LK_RELEASE); if (ovp == NULLVP) return (EBADF); @@ -941,7 +929,7 @@ unionfs_poll(struct vop_poll_args *ap) unionfs_get_node_status(unp, ap->a_td, &unsp); ovp = (unsp->uns_upper_opencnt ? unp->un_uppervp : unp->un_lowervp); unionfs_tryrem_node_status(unp, unsp); - VOP_UNLOCK(ap->a_vp, 0); + VOP_UNLOCK(ap->a_vp, LK_RELEASE); if (ovp == NULLVP) return (EBADF); @@ -1001,7 +989,7 @@ unionfs_remove(struct vop_remove_args *a ump = NULL; vp = uvp = lvp = NULLVP; /* search vnode */ - VOP_UNLOCK(ap->a_vp, 0); + VOP_UNLOCK(ap->a_vp, LK_RELEASE); error = unionfs_relookup(udvp, &vp, cnp, &cn, td, cnp->cn_nameptr, strlen(cnp->cn_nameptr), DELETE); if (error != 0 && error != ENOENT) { @@ -1204,7 +1192,7 @@ unionfs_rename(struct vop_rename_args *a if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0) goto unionfs_rename_abort; error = unionfs_copyfile(unp, 1, fcnp->cn_cred, td); - VOP_UNLOCK(fvp, 0); + VOP_UNLOCK(fvp, LK_RELEASE); if (error != 0) goto unionfs_rename_abort; break; @@ -1212,7 +1200,7 @@ unionfs_rename(struct vop_rename_args *a if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0) goto unionfs_rename_abort; error = unionfs_mkshadowdir(ump, rfdvp, unp, fcnp, td); - VOP_UNLOCK(fvp, 0); + VOP_UNLOCK(fvp, LK_RELEASE); if (error != 0) goto unionfs_rename_abort; break; @@ -1269,13 +1257,13 @@ unionfs_rename(struct vop_rename_args *a if ((error = vn_lock(fdvp, LK_EXCLUSIVE)) != 0) goto unionfs_rename_abort; error = unionfs_relookup_for_delete(fdvp, fcnp, td); - VOP_UNLOCK(fdvp, 0); + VOP_UNLOCK(fdvp, LK_RELEASE); if (error != 0) goto unionfs_rename_abort; /* Locke of tvp is canceled in order to avoid recursive lock. */ if (tvp != NULLVP && tvp != tdvp) - VOP_UNLOCK(tvp, 0); + VOP_UNLOCK(tvp, LK_RELEASE); error = unionfs_relookup_for_rename(tdvp, tcnp, td); if (tvp != NULLVP && tvp != tdvp) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); @@ -1293,11 +1281,11 @@ unionfs_rename(struct vop_rename_args *a } if (ltdvp != NULLVP) - VOP_UNLOCK(ltdvp, 0); + VOP_UNLOCK(ltdvp, LK_RELEASE); if (tdvp != rtdvp) vrele(tdvp); if (ltvp != NULLVP) - VOP_UNLOCK(ltvp, 0); + VOP_UNLOCK(ltvp, LK_RELEASE); if (tvp != rtvp && tvp != NULLVP) { if (rtvp == NULLVP) vput(tvp); @@ -1371,7 +1359,7 @@ unionfs_mkdir(struct vop_mkdir_args *ap) } if ((error = VOP_MKDIR(udvp, &uvp, cnp, ap->a_vap)) == 0) { - VOP_UNLOCK(uvp, 0); + VOP_UNLOCK(uvp, LK_RELEASE); cnp->cn_lkflags = LK_EXCLUSIVE; error = unionfs_nodeget(ap->a_dvp->v_mount, uvp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, td); @@ -1427,7 +1415,9 @@ unionfs_rmdir(struct vop_rmdir_args *ap) ump = MOUNTTOUNIONFSMOUNT(ap->a_vp->v_mount); if (ump->um_whitemode == UNIONFS_WHITE_ALWAYS || lvp != NULLVP) cnp->cn_flags |= DOWHITEOUT; - error = VOP_RMDIR(udvp, uvp, cnp); + error = unionfs_relookup_for_delete(ap->a_dvp, cnp, td); + if (!error) + error = VOP_RMDIR(udvp, uvp, cnp); } else if (lvp != NULLVP) error = unionfs_mkwhiteout(udvp, cnp, td, unp->un_path); @@ -1467,7 +1457,7 @@ unionfs_symlink(struct vop_symlink_args if (udvp != NULLVP) { error = VOP_SYMLINK(udvp, &uvp, cnp, ap->a_vap, ap->a_target); if (error == 0) { - VOP_UNLOCK(uvp, 0); + VOP_UNLOCK(uvp, LK_RELEASE); cnp->cn_lkflags = LK_EXCLUSIVE; error = unionfs_nodeget(ap->a_dvp->v_mount, uvp, NULLVP, ap->a_dvp, ap->a_vpp, cnp, td); @@ -1487,9 +1477,11 @@ unionfs_readdir(struct vop_readdir_args int error; int eofflag; int locked; + int uio_offset_bk; struct unionfs_node *unp; struct unionfs_node_status *unsp; struct uio *uio; + struct vnode *vp; struct vnode *uvp; struct vnode *lvp; struct thread *td; @@ -1505,41 +1497,50 @@ unionfs_readdir(struct vop_readdir_args error = 0; eofflag = 0; locked = 0; - unp = VTOUNIONFS(ap->a_vp); + uio_offset_bk = 0; uio = ap->a_uio; - uvp = unp->un_uppervp; - lvp = unp->un_lowervp; + uvp = NULLVP; + lvp = NULLVP; td = uio->uio_td; ncookies_bk = 0; cookies_bk = NULL; - if (ap->a_vp->v_type != VDIR) + vp = ap->a_vp; + if (vp->v_type != VDIR) return (ENOTDIR); - /* check opaque */ - if (uvp != NULLVP && lvp != NULLVP) { - if ((error = VOP_GETATTR(uvp, &va, ap->a_cred)) != 0) - goto unionfs_readdir_exit; - if (va.va_flags & OPAQUE) - lvp = NULLVP; - } - /* check the open count. unionfs needs to open before readdir. */ - if (VOP_ISLOCKED(ap->a_vp) != LK_EXCLUSIVE) { - vn_lock(ap->a_vp, LK_UPGRADE | LK_RETRY); + if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) { + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); locked = 1; } - unionfs_get_node_status(unp, td, &unsp); - if ((uvp != NULLVP && unsp->uns_upper_opencnt <= 0) || - (lvp != NULLVP && unsp->uns_lower_opencnt <= 0)) { - unionfs_tryrem_node_status(unp, unsp); + unp = VTOUNIONFS(vp); + if (unp == NULL) error = EBADF; + else { + uvp = unp->un_uppervp; + lvp = unp->un_lowervp; + unionfs_get_node_status(unp, td, &unsp); + if ((uvp != NULLVP && unsp->uns_upper_opencnt <= 0) || + (lvp != NULLVP && unsp->uns_lower_opencnt <= 0)) { + unionfs_tryrem_node_status(unp, unsp); + error = EBADF; + } } - if (locked == 1) - vn_lock(ap->a_vp, LK_DOWNGRADE | LK_RETRY); + if (locked) + vn_lock(vp, LK_DOWNGRADE | LK_RETRY); if (error != 0) goto unionfs_readdir_exit; + /* check opaque */ + if (uvp != NULLVP && lvp != NULLVP) { + if ((error = VOP_GETATTR(uvp, &va, ap->a_cred)) != 0) + goto unionfs_readdir_exit; + if (va.va_flags & OPAQUE) + lvp = NULLVP; + } + /* upper only */ if (uvp != NULLVP && lvp == NULLVP) { error = VOP_READDIR(uvp, uio, ap->a_cred, ap->a_eofflag, @@ -1576,7 +1577,7 @@ unionfs_readdir(struct vop_readdir_args unsp->uns_readdir_status = 1; /* - * ufs(and other fs) needs size of uio_resid larger than + * UFS(and other FS) needs size of uio_resid larger than * DIRBLKSIZ. * size of DIRBLKSIZ equals DEV_BSIZE. * (see: ufs/ufs/ufs_vnops.c ufs_readdir func , ufs/ufs/dir.h) @@ -1585,7 +1586,7 @@ unionfs_readdir(struct vop_readdir_args goto unionfs_readdir_exit; /* - * backup cookies + * Backup cookies. * It prepares to readdir in lower. */ if (ap->a_ncookies != NULL) { @@ -1601,6 +1602,11 @@ unionfs_readdir(struct vop_readdir_args /* initialize for readdir in lower */ if (unsp->uns_readdir_status == 1) { unsp->uns_readdir_status = 2; + /* + * Backup uio_offset. See the comment after the + * VOP_READDIR call on the lower layer. + */ + uio_offset_bk = uio->uio_offset; uio->uio_offset = 0; } @@ -1612,6 +1618,19 @@ unionfs_readdir(struct vop_readdir_args error = VOP_READDIR(lvp, uio, ap->a_cred, ap->a_eofflag, ap->a_ncookies, ap->a_cookies); + /* + * We can't return an uio_offset of 0: this would trigger an + * infinite loop, because the next call to unionfs_readdir would + * always restart with the upper layer (uio_offset == 0) and + * always return some data. + * + * This happens when the lower layer root directory is removed. + * (A root directory deleting of unionfs should not be permitted. + * But current VFS can not do it.) + */ + if (uio->uio_offset == 0) + uio->uio_offset = uio_offset_bk; + if (cookies_bk != NULL) { /* merge cookies */ int size; @@ -1743,18 +1762,66 @@ unionfs_print(struct vop_print_args *ap) } static int -unionfs_get_llt_revlock(int flags) +unionfs_islocked(struct vop_islocked_args *ap) { - int count; + struct unionfs_node *unp; - flags &= LK_TYPE_MASK; - for (count = 0; un_llt[count].lock != 0; count++) { - if (flags == un_llt[count].lock) { - return un_llt[count].revlock; - } + KASSERT_UNIONFS_VNODE(ap->a_vp); + + unp = VTOUNIONFS(ap->a_vp); + if (unp == NULL) + return (vop_stdislocked(ap)); + + if (unp->un_uppervp != NULLVP) + return (VOP_ISLOCKED(unp->un_uppervp)); + if (unp->un_lowervp != NULLVP) + return (VOP_ISLOCKED(unp->un_lowervp)); + return (vop_stdislocked(ap)); +} + +static int +unionfs_get_llt_revlock(struct vnode *vp, int flags) +{ + int revlock; + + revlock = 0; + + switch (flags & LK_TYPE_MASK) { + case LK_SHARED: + if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) + revlock = LK_UPGRADE; + else + revlock = LK_RELEASE; + break; + case LK_EXCLUSIVE: + case LK_UPGRADE: + revlock = LK_RELEASE; + break; + case LK_DOWNGRADE: + revlock = LK_UPGRADE; + break; + default: + break; } - return 0; + return (revlock); +} + +/* + * The state of an acquired lock is adjusted similarly to + * the time of error generating. + * flags: LK_RELEASE or LK_UPGRADE + */ +static void +unionfs_revlock(struct vnode *vp, int flags) +{ + if (flags & LK_RELEASE) + VOP_UNLOCK(vp, flags); + else { + /* UPGRADE */ + if (vn_lock(vp, flags) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + } } static int @@ -1763,6 +1830,7 @@ unionfs_lock(struct vop_lock1_args *ap) int error; int flags; int revlock; + int interlock; int uhold; struct mount *mp; struct unionfs_mount *ump; @@ -1774,15 +1842,13 @@ unionfs_lock(struct vop_lock1_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); error = 0; + interlock = 1; uhold = 0; flags = ap->a_flags; vp = ap->a_vp; if (LK_RELEASE == (flags & LK_TYPE_MASK) || !(flags & LK_TYPE_MASK)) - return (VOP_UNLOCK(vp, flags)); - - if ((revlock = unionfs_get_llt_revlock(flags)) == 0) - panic("unknown lock type: 0x%x", flags & LK_TYPE_MASK); + return (VOP_UNLOCK(vp, flags | LK_RELEASE)); if ((flags & LK_INTERLOCK) == 0) VI_LOCK(vp); @@ -1798,6 +1864,9 @@ unionfs_lock(struct vop_lock1_args *ap) lvp = unp->un_lowervp; uvp = unp->un_uppervp; + if ((revlock = unionfs_get_llt_revlock(vp, flags)) == 0) + panic("unknown lock type: 0x%x", flags & LK_TYPE_MASK); + if ((mp->mnt_kern_flag & MNTK_MPSAFE) != 0 && (vp->v_iflag & VI_OWEINACT) != 0) flags |= LK_NOWAIT; @@ -1811,6 +1880,23 @@ unionfs_lock(struct vop_lock1_args *ap) flags |= LK_CANRECURSE; if (lvp != NULLVP) { + if (uvp != NULLVP && flags & LK_UPGRADE) { + /* Share Lock is once released and a deadlock is avoided. */ + VI_LOCK_FLAGS(uvp, MTX_DUPOK); + vholdl(uvp); + uhold = 1; + VI_UNLOCK(vp); + VOP_UNLOCK(uvp, LK_RELEASE | LK_INTERLOCK); + VI_LOCK(vp); + unp = VTOUNIONFS(vp); + if (unp == NULL) { + /* vnode is released. */ + VI_UNLOCK(vp); + VOP_UNLOCK(lvp, LK_RELEASE); + vdrop(uvp); + return (EBUSY); + } + } VI_LOCK_FLAGS(lvp, MTX_DUPOK); flags |= LK_INTERLOCK; vholdl(lvp); @@ -1823,19 +1909,28 @@ unionfs_lock(struct vop_lock1_args *ap) VI_LOCK(vp); unp = VTOUNIONFS(vp); if (unp == NULL) { + /* vnode is released. */ VI_UNLOCK(vp); if (error == 0) - VOP_UNLOCK(lvp, 0); + VOP_UNLOCK(lvp, LK_RELEASE); vdrop(lvp); + if (uhold != 0) + vdrop(uvp); return (vop_stdlock(ap)); } } if (error == 0 && uvp != NULLVP) { + if (uhold && flags & LK_UPGRADE) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } VI_LOCK_FLAGS(uvp, MTX_DUPOK); flags |= LK_INTERLOCK; - vholdl(uvp); - uhold = 1; + if (uhold == 0) { + vholdl(uvp); + uhold = 1; + } VI_UNLOCK(vp); ap->a_flags &= ~LK_INTERLOCK; @@ -1845,30 +1940,27 @@ unionfs_lock(struct vop_lock1_args *ap) VI_LOCK(vp); unp = VTOUNIONFS(vp); if (unp == NULL) { + /* vnode is released. */ VI_UNLOCK(vp); - if (error == 0) { - VOP_UNLOCK(uvp, 0); - if (lvp != NULLVP) - VOP_UNLOCK(lvp, 0); - } - if (lvp != NULLVP) - vdrop(lvp); + if (error == 0) + VOP_UNLOCK(uvp, LK_RELEASE); vdrop(uvp); + if (lvp != NULLVP) { + VOP_UNLOCK(lvp, LK_RELEASE); + vdrop(lvp); + } return (vop_stdlock(ap)); } - if (error != 0 && lvp != NULLVP) { + /* rollback */ VI_UNLOCK(vp); - if ((revlock & LK_TYPE_MASK) == LK_RELEASE) - VOP_UNLOCK(lvp, revlock); - else - vn_lock(lvp, revlock | LK_RETRY); - goto unionfs_lock_abort; + unionfs_revlock(lvp, revlock); + interlock = 0; } } - VI_UNLOCK(vp); -unionfs_lock_abort: + if (interlock) + VI_UNLOCK(vp); if (lvp != NULLVP) vdrop(lvp); if (uhold != 0) @@ -2013,7 +2105,7 @@ unionfs_advlock(struct vop_advlock_args unionfs_tryrem_node_status(unp, unsp); } - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); error = VOP_ADVLOCK(uvp, ap->a_id, ap->a_op, ap->a_fl, ap->a_flags); @@ -2022,7 +2114,7 @@ unionfs_advlock(struct vop_advlock_args return error; unionfs_advlock_abort: - VOP_UNLOCK(vp, 0); + VOP_UNLOCK(vp, LK_RELEASE); UNIONFS_INTERNAL_DEBUG("unionfs_advlock: leave (%d)\n", error); @@ -2150,7 +2242,8 @@ unionfs_openextattr(struct vop_openextat error = VOP_OPENEXTATTR(tvp, ap->a_cred, ap->a_td); if (error == 0) { - vn_lock(vp, LK_UPGRADE | LK_RETRY); + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (tvp == unp->un_uppervp) unp->un_flag |= UNIONFS_OPENEXTU; else @@ -2186,7 +2279,8 @@ unionfs_closeextattr(struct vop_closeext error = VOP_CLOSEEXTATTR(tvp, ap->a_commit, ap->a_cred, ap->a_td); if (error == 0) { - vn_lock(vp, LK_UPGRADE | LK_RETRY); + if (vn_lock(vp, LK_UPGRADE) != 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (tvp == unp->un_uppervp) unp->un_flag &= ~UNIONFS_OPENEXTU; else @@ -2435,6 +2529,7 @@ struct vop_vector unionfs_vnodeops = { .vop_getextattr = unionfs_getextattr, .vop_getwritemount = unionfs_getwritemount, .vop_inactive = unionfs_inactive, + .vop_islocked = unionfs_islocked, .vop_ioctl = unionfs_ioctl, .vop_link = unionfs_link, .vop_listextattr = unionfs_listextattr, From owner-svn-src-head@FreeBSD.ORG Tue May 1 08:19:30 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9A0E106566B; Tue, 1 May 2012 08:19:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3B088FC14; Tue, 1 May 2012 08:19:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q418JTAq009950; Tue, 1 May 2012 08:19:29 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q418JT7k009948; Tue, 1 May 2012 08:19:29 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205010819.q418JT7k009948@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 May 2012 08:19:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234868 - head/sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 08:19:30 -0000 Author: mav Date: Tue May 1 08:19:29 2012 New Revision: 234868 URL: http://svn.freebsd.org/changeset/base/234868 Log: Improve DDF metadata writing. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Tue May 1 07:46:30 2012 (r234867) +++ head/sys/geom/raid/md_ddf.c Tue May 1 08:19:29 2012 (r234868) @@ -89,9 +89,9 @@ struct g_raid_md_ddf_pervolume { struct g_raid_md_ddf_object { struct g_raid_md_object mdio_base; struct ddf_meta mdio_meta; + int mdio_starting; struct callout mdio_start_co; /* STARTING state timer. */ int mdio_started; - int mdio_incomplete; struct root_hold_token *mdio_rootmount; /* Root mount delay token. */ }; @@ -835,7 +835,8 @@ ddf_vol_meta_create(struct ddf_vol_meta } static void -ddf_vol_meta_update(struct ddf_vol_meta *dst, struct ddf_meta *src, uint8_t *GUID) +ddf_vol_meta_update(struct ddf_vol_meta *dst, struct ddf_meta *src, + uint8_t *GUID, int started) { struct ddf_header *hdr; struct ddf_vd_entry *vde; @@ -850,15 +851,15 @@ ddf_vol_meta_update(struct ddf_vol_meta size = GET16(src, hdr->Configuration_Record_Length) * src->sectorsize; if (dst->vdc == NULL || - ((int32_t)(GET32D(src, vdc->Sequence_Number) - - GET32(dst, vdc->Sequence_Number))) > 0) + (!started && ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, vdc->Sequence_Number))) > 0)) vnew = 1; else vnew = 0; if (dst->bvdc[bvd] == NULL || - ((int32_t)(GET32D(src, vdc->Sequence_Number) - - GET32(dst, bvdc[bvd]->Sequence_Number))) > 0) + (!started && ((int32_t)(GET32D(src, vdc->Sequence_Number) - + GET32(dst, bvdc[bvd]->Sequence_Number))) > 0)) bvnew = 1; else bvnew = 0; @@ -1803,6 +1804,7 @@ g_raid_md_ddf_start(struct g_raid_volume struct g_raid_disk *disk; struct g_raid_md_object *md; struct g_raid_md_ddf_pervolume *pv; + struct g_raid_md_ddf_object *mdi; struct ddf_vol_meta *vmeta; struct ddf_vdc_record *vdc; uint64_t *val2; @@ -1810,6 +1812,7 @@ g_raid_md_ddf_start(struct g_raid_volume sc = vol->v_softc; md = sc->sc_md; + mdi = (struct g_raid_md_ddf_object *)md; pv = vol->v_md_data; vmeta = &pv->pv_meta; vdc = vmeta->vdc; @@ -1862,6 +1865,7 @@ g_raid_md_ddf_start(struct g_raid_volume } pv->pv_started = 1; + mdi->mdio_starting--; callout_stop(&pv->pv_start_co); G_RAID_DEBUG1(0, sc, "Volume started."); g_raid_md_write_ddf(md, vol, NULL, NULL); @@ -1948,13 +1952,13 @@ g_raid_md_ddf_new_disk(struct g_raid_dis callout_reset(&pv->pv_start_co, g_raid_start_timeout * hz, g_raid_ddf_go, vol); + mdi->mdio_starting++; } else pv = vol->v_md_data; /* If we haven't started yet - check metadata freshness. */ vmeta = &pv->pv_meta; - if (vmeta->hdr == NULL || !pv->pv_started) - ddf_vol_meta_update(vmeta, pdmeta, vdc->VD_GUID); + ddf_vol_meta_update(vmeta, pdmeta, vdc->VD_GUID, pv->pv_started); } if (spare == 1) { @@ -2649,26 +2653,29 @@ g_raid_md_write_ddf(struct g_raid_md_obj if (sc->sc_stopping == G_RAID_DESTROY_HARD) return (0); - /* Generate new per-volume metadata for affected volumes. */ - TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) { - if (vol->v_stopping) - continue; - - /* Skip volumes not related to specified targets. */ - if (tvol != NULL && vol != tvol) - continue; - if (tsd != NULL && vol != tsd->sd_volume) - continue; - if (tdisk != NULL) { - for (i = 0; i < vol->v_disks_count; i++) { - if (vol->v_subdisks[i].sd_disk == tdisk) - break; - } - if (i >= vol->v_disks_count) + /* + * Clear disk flags to let only really needed ones to be reset. + * Do it only if there are no volumes in starting state now, + * as they can update disk statuses yet and we may kill innocent. + */ + if (mdi->mdio_starting == 0) { + for (i = 0; i < GET16(gmeta, pdr->Populated_PDEs); i++) { + if (isff(gmeta->pdr->entry[i].PD_GUID, 24)) continue; + SET16(gmeta, pdr->entry[i].PD_Type, + GET16(gmeta, pdr->entry[i].PD_Type) & + ~DDF_PDE_PARTICIPATING); + if ((GET16(gmeta, pdr->entry[i].PD_State) & + DDF_PDE_PFA) == 0) + SET16(gmeta, pdr->entry[i].PD_State, 0); } + } + /* Generate/update new per-volume metadata. */ + TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) { pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; + if (vol->v_stopping || !pv->pv_started) + continue; vmeta = &pv->pv_meta; SET32(vmeta, vdc->Sequence_Number, @@ -2711,7 +2718,9 @@ g_raid_md_write_ddf(struct g_raid_md_obj SET8(vmeta, vde->VD_State, DDF_VDE_PARTIAL); else SET8(vmeta, vde->VD_State, DDF_VDE_OPTIMAL); - if (vol->v_dirty) + if (vol->v_dirty || + g_raid_nsubdisks(vol, G_RAID_SUBDISK_S_STALE) > 0 || + g_raid_nsubdisks(vol, G_RAID_SUBDISK_S_RESYNC) > 0) SET8(vmeta, vde->VD_State, GET8(vmeta, vde->VD_State) | DDF_VDE_DIRTY); SET8(vmeta, vde->Init_State, DDF_VDE_INIT_FULL); // XXX @@ -2719,45 +2728,50 @@ g_raid_md_write_ddf(struct g_raid_md_obj for (i = 0; i < vol->v_disks_count; i++) { sd = &vol->v_subdisks[i]; - disk = sd->sd_disk; - if (disk == NULL) - continue; - pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; bvd = i / GET16(vmeta, vdc->Primary_Element_Count); pos = i % GET16(vmeta, vdc->Primary_Element_Count); - if (vmeta->bvdc[bvd] == NULL) { - size = GET16(vmeta, - hdr->Configuration_Record_Length) * - vmeta->sectorsize; - vmeta->bvdc[bvd] = malloc(size, M_MD_DDF, M_WAITOK); - memcpy(vmeta->bvdc[bvd], vmeta->vdc, size); + disk = sd->sd_disk; + if (disk != NULL) { + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + if (vmeta->bvdc[bvd] == NULL) { + size = GET16(vmeta, + hdr->Configuration_Record_Length) * + vmeta->sectorsize; + vmeta->bvdc[bvd] = malloc(size, + M_MD_DDF, M_WAITOK); + memset(vmeta->bvdc[bvd], 0xff, size); + } + memcpy(vmeta->bvdc[bvd], vmeta->vdc, + sizeof(struct ddf_vdc_record)); SET8(vmeta, bvdc[bvd]->Secondary_Element_Seq, bvd); + SET64(vmeta, bvdc[bvd]->Block_Count, + sd->sd_size / vol->v_sectorsize); + SET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos], + GET32(&pd->pd_meta, pdd->PD_Reference)); + val2 = (uint64_t *)&(vmeta->bvdc[bvd]->Physical_Disk_Sequence[ + GET16(vmeta, hdr->Max_Primary_Element_Entries)]); + SET64P(vmeta, val2 + pos, + sd->sd_offset / vol->v_sectorsize); } - SET64(vmeta, bvdc[bvd]->Block_Count, - sd->sd_size / vol->v_sectorsize); - SET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos], - GET32(&pd->pd_meta, pdd->PD_Reference)); - val2 = (uint64_t *)&(vmeta->bvdc[bvd]->Physical_Disk_Sequence[ - GET16(vmeta, hdr->Max_Primary_Element_Entries)]); - SET64P(vmeta, val2 + pos, - sd->sd_offset / vol->v_sectorsize); + if (vmeta->bvdc[bvd] == NULL) + continue; j = ddf_meta_find_pd(gmeta, NULL, - GET32(&pd->pd_meta, pdd->PD_Reference)); + GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[pos])); if (j < 0) continue; SET32(gmeta, pdr->entry[j].PD_Type, GET32(gmeta, pdr->entry[j].PD_Type) | DDF_PDE_PARTICIPATING); - if (sd->sd_state == G_RAID_SUBDISK_S_FAILED) + if (sd->sd_state == G_RAID_SUBDISK_S_NONE) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED | DDF_PDE_PFA); - else if (sd->sd_state <= G_RAID_SUBDISK_S_UNINITIALIZED) + DDF_PDE_FAILED | DDF_PDE_MISSING); + else if (sd->sd_state == G_RAID_SUBDISK_S_FAILED) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED); - else if (sd->sd_state < G_RAID_SUBDISK_S_ACTIVE) + DDF_PDE_FAILED | DDF_PDE_PFA); + else if (sd->sd_state <= G_RAID_SUBDISK_S_REBUILD) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | DDF_PDE_FAILED); @@ -2768,17 +2782,33 @@ g_raid_md_write_ddf(struct g_raid_md_obj } } + /* Remove disks without "participating" flag (unused). */ + for (i = 0, j = -1; i < GET16(gmeta, pdr->Populated_PDEs); i++) { + if (isff(gmeta->pdr->entry[i].PD_GUID, 24)) + continue; + if (GET16(gmeta, pdr->entry[i].PD_Type) & DDF_PDE_PARTICIPATING) + j = i; + else + memset(&gmeta->pdr->entry[i], 0xff, + sizeof(struct ddf_pd_entry)); + } + SET16(gmeta, pdr->Populated_PDEs, j + 1); + + /* Update per-disk metadata and write them. */ TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; if (disk->d_state != G_RAID_DISK_S_ACTIVE) continue; + /* Update PDR. */ memcpy(pd->pd_meta.pdr, gmeta->pdr, GET32(&pd->pd_meta, hdr->pdr_length) * pd->pd_meta.sectorsize); - TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { - vol = sd->sd_volume; + /* Update VDR. */ + SET16(&pd->pd_meta, vdr->Populated_VDEs, 0); + TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) { + if (vol->v_stopping) + continue; pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; - vmeta = &pv->pv_meta; i = ddf_meta_find_vd(&pd->pd_meta, pv->pv_meta.vde->VD_GUID); if (i < 0) @@ -2787,14 +2817,22 @@ g_raid_md_write_ddf(struct g_raid_md_obj memcpy(&pd->pd_meta.vdr->entry[i], pv->pv_meta.vde, sizeof(struct ddf_vd_entry)); + } + /* Update VDC. */ + TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { + vol = sd->sd_volume; + if (vol->v_stopping) + continue; + pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; + vmeta = &pv->pv_meta; vdc = ddf_meta_find_vdc(&pd->pd_meta, - pv->pv_meta.vde->VD_GUID); + vmeta->vde->VD_GUID); if (vdc == NULL) vdc = ddf_meta_find_vdc(&pd->pd_meta, NULL); if (vdc != NULL) { bvd = sd->sd_pos / GET16(vmeta, vdc->Primary_Element_Count); - memcpy(vdc, pv->pv_meta.bvdc[bvd], + memcpy(vdc, vmeta->bvdc[bvd], GET16(&pd->pd_meta, hdr->Configuration_Record_Length) * pd->pd_meta.sectorsize); From owner-svn-src-head@FreeBSD.ORG Tue May 1 09:21:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 679EE106564A; Tue, 1 May 2012 09:21:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 520B48FC08; Tue, 1 May 2012 09:21:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q419LM2K012018; Tue, 1 May 2012 09:21:22 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q419LMGY012016; Tue, 1 May 2012 09:21:22 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205010921.q419LMGY012016@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 May 2012 09:21:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234869 - head/sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 09:21:22 -0000 Author: mav Date: Tue May 1 09:21:21 2012 New Revision: 234869 URL: http://svn.freebsd.org/changeset/base/234869 Log: Implement volume deletion if disk has more then one partition. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Tue May 1 08:19:29 2012 (r234868) +++ head/sys/geom/raid/md_ddf.c Tue May 1 09:21:21 2012 (r234869) @@ -172,6 +172,13 @@ static struct g_raid_md_class g_raid_md_ #define SET32D(m, f, v) SET32P((m), &(f), (v)) #define SET64D(m, f, v) SET64P((m), &(f), (v)) +#define GETCRNUM(m) (GET32((m), hdr->cr_length) / \ + GET16((m), hdr->Configuration_Record_Length)) + +#define GETVDCPTR(m, n) ((struct ddf_vdc_record *)((uint8_t *)(m)->cr + \ + (n) * GET16((m), hdr->Configuration_Record_Length) * \ + (m)->sectorsize)) + static int isff(uint8_t *buf, int size) { @@ -254,7 +261,7 @@ g_raid_md_ddf_print(struct ddf_meta *met GET16(meta, cdr->Controller_Type.SubVendor_ID), GET16(meta, cdr->Controller_Type.SubDevice_ID)); printf("Product_ID '%.16s'\n", (char *)&meta->cdr->Product_ID[0]); - printf("**** Physical Disk Data ****\n"); + printf("**** Physical Disk Records ****\n"); printf("Populated_PDEs %u\n", GET16(meta, pdr->Populated_PDEs)); printf("Max_PDE_Supported %u\n", GET16(meta, pdr->Max_PDE_Supported)); for (j = 0; j < GET16(meta, pdr->Populated_PDEs); j++) { @@ -276,7 +283,7 @@ g_raid_md_ddf_print(struct ddf_meta *met printf("Block_Size %u\n", GET16(meta, pdr->entry[j].Block_Size)); } - printf("**** Virtual Disk Data ****\n"); + printf("**** Virtual Disk Records ****\n"); printf("Populated_VDEs %u\n", GET16(meta, vdr->Populated_VDEs)); printf("Max_VDE_Supported %u\n", GET16(meta, vdr->Max_VDE_Supported)); for (j = 0; j < GET16(meta, vdr->Populated_VDEs); j++) { @@ -299,11 +306,9 @@ g_raid_md_ddf_print(struct ddf_meta *met (char *)&meta->vdr->entry[j].VD_Name); } printf("**** Configuration Records ****\n"); - num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (j = 0; j < num; j++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - j * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, j); val = GET32D(meta, vdc->Signature); switch (val) { case DDF_VDCR_SIGNATURE: @@ -463,11 +468,9 @@ ddf_meta_find_vdc(struct ddf_meta *meta, struct ddf_vdc_record *vdc; int i, num; - num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - i * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, i); if (GUID != NULL) { if (GET32D(meta, vdc->Signature) == DDF_VDCR_SIGNATURE && memcmp(vdc->VD_GUID, GUID, 24) == 0) @@ -486,11 +489,9 @@ ddf_meta_count_vdc(struct ddf_meta *meta int i, num, cnt; cnt = 0; - num = GET32(meta, hdr->cr_length) / GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - i * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, i); if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) continue; if (GUID == NULL || memcmp(vdc->VD_GUID, GUID, 24) == 0) @@ -937,12 +938,9 @@ ddf_meta_unused_range(struct ddf_meta *m beg[0] = 0; end[0] = GET64(meta, pdr->entry[pos].Configured_Size); n = 1; - num = GET32(meta, hdr->cr_length) / - GET16(meta, hdr->Configuration_Record_Length); + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + - i * GET16(meta, hdr->Configuration_Record_Length) * - meta->sectorsize); + vdc = GETVDCPTR(meta, i); if (GET32D(meta, vdc->Signature) != DDF_VDCR_SIGNATURE) continue; for (pos = 0; pos < GET16D(meta, vdc->Primary_Element_Count); pos++) @@ -1261,11 +1259,10 @@ err: if (error != 0) goto err; - size = GET16(meta, hdr->Configuration_Record_Length); - num = GET32(meta, hdr->cr_length) / size; - size *= ss; + size = GET16(meta, hdr->Configuration_Record_Length) * ss; + num = GETCRNUM(meta); for (i = 0; i < num; i++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)meta->cr + i * size); + vdc = GETVDCPTR(meta, i); SET32D(meta, vdc->CRC, 0xffffffff); SET32D(meta, vdc->CRC, crc32(vdc, size)); } @@ -1518,9 +1515,7 @@ g_raid_md_ddf_supported(int level, int q if (qual != G_RAID_VOLUME_RLQ_R1EA && qual != G_RAID_VOLUME_RLQ_R1EO) return (0); - if (disks < 2) - return (0); - if (disks % 2 != 0) + if (disks < 3) return (0); break; case G_RAID_VOLUME_RL_SINGLE: @@ -1922,11 +1917,9 @@ g_raid_md_ddf_new_disk(struct g_raid_dis else ddf_meta_update(&mdi->mdio_meta, pdmeta); - num = GET32(pdmeta, hdr->cr_length) / GET16(pdmeta, hdr->Configuration_Record_Length); + num = GETCRNUM(pdmeta); for (j = 0; j < num; j++) { - vdc = (struct ddf_vdc_record *)((uint8_t *)pdmeta->cr + - j * GET16(pdmeta, hdr->Configuration_Record_Length) * - pdmeta->sectorsize); + vdc = GETVDCPTR(pdmeta, j); val = GET32D(pdmeta, vdc->Signature); if (val == DDF_SA_SIGNATURE && spare == -1) @@ -2819,6 +2812,17 @@ g_raid_md_write_ddf(struct g_raid_md_obj sizeof(struct ddf_vd_entry)); } /* Update VDC. */ + if (mdi->mdio_starting == 0) { + /* Remove all VDCs to restore needed later. */ + j = GETCRNUM(&pd->pd_meta); + for (i = 0; i < j; i++) { + vdc = GETVDCPTR(&pd->pd_meta, i); + if (GET32D(&pd->pd_meta, vdc->Signature) != + DDF_VDCR_SIGNATURE) + continue; + SET32D(&pd->pd_meta, vdc->Signature, 0xffffffff); + } + } TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { vol = sd->sd_volume; if (vol->v_stopping) @@ -2906,12 +2910,15 @@ static int g_raid_md_free_volume_ddf(struct g_raid_md_object *md, struct g_raid_volume *vol) { + struct g_raid_md_ddf_object *mdi; struct g_raid_md_ddf_pervolume *pv; + mdi = (struct g_raid_md_ddf_object *)md; pv = (struct g_raid_md_ddf_pervolume *)vol->v_md_data; ddf_vol_meta_free(&pv->pv_meta); if (!pv->pv_started) { pv->pv_started = 1; + mdi->mdio_starting--; callout_stop(&pv->pv_start_co); } return (0); From owner-svn-src-head@FreeBSD.ORG Tue May 1 10:16:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE70B106564A; Tue, 1 May 2012 10:16:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FE108FC0C; Tue, 1 May 2012 10:16:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41AGD2J020223; Tue, 1 May 2012 10:16:13 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41AGDMw020221; Tue, 1 May 2012 10:16:13 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205011016.q41AGDMw020221@svn.freebsd.org> From: Baptiste Daroussin Date: Tue, 1 May 2012 10:16:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234870 - head/usr.sbin/pkg X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 10:16:13 -0000 Author: bapt Date: Tue May 1 10:16:12 2012 New Revision: 234870 URL: http://svn.freebsd.org/changeset/base/234870 Log: - close the open file after fetching - create a default /usr/local/etc/pkg.conf Approved by: des (mentor) Modified: head/usr.sbin/pkg/pkg.c Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Tue May 1 09:21:21 2012 (r234869) +++ head/usr.sbin/pkg/pkg.c Tue May 1 10:16:12 2012 (r234870) @@ -282,7 +282,10 @@ static int bootstrap_pkg(void) { FILE *remote; + FILE *config; + char *site; char url[MAXPATHLEN]; + char conf[MAXPATHLEN]; char abi[BUFSIZ]; char tmppkg[MAXPATHLEN]; char buf[10240]; @@ -290,7 +293,6 @@ bootstrap_pkg(void) int fd, retry, ret; struct url_stat st; off_t done, r; - time_t begin_dl; time_t now; time_t last; @@ -298,6 +300,7 @@ bootstrap_pkg(void) last = 0; ret = -1; remote = NULL; + config = NULL; printf("Bootstrapping pkg please wait\n"); @@ -307,7 +310,7 @@ bootstrap_pkg(void) } if (getenv("PACKAGESITE") != NULL) - snprintf(url, MAXPATHLEN, "%s/pkg.txz", getenv("PACKAGESITE")); + snprintf(url, MAXPATHLEN, "%s/Latest/pkg.txz", getenv("PACKAGESITE")); else snprintf(url, MAXPATHLEN, "%s/%s/latest/Latest/pkg.txz", getenv("PACKAGEROOT") ? getenv("PACKAGEROOT") : _PKGS_URL, @@ -331,7 +334,6 @@ bootstrap_pkg(void) if (remote == NULL) goto fetchfail; - begin_dl = time(NULL); while (done < st.size) { if ((r = fread(buf, 1, sizeof(buf), remote)) < 1) break; @@ -353,12 +355,34 @@ bootstrap_pkg(void) if ((ret = extract_pkg_static(fd, pkgstatic, MAXPATHLEN)) == 0) ret = install_pkg_static(pkgstatic, tmppkg); + snprintf(conf, MAXPATHLEN, "%s/etc/pkg.conf", + getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE); + + if (access(conf, R_OK) == -1) { + site = strrchr(url, '/'); + if (site == NULL) + goto cleanup; + site[0] = '\0'; + site = strrchr(url, '/'); + if (site == NULL) + goto cleanup; + site[0] = '\0'; + + config = fopen(conf, "w+"); + if (config == NULL) + goto cleanup; + fprintf(config, "packagesite: %s", url); + fclose(config); + } + goto cleanup; fetchfail: warnx("Error fetching %s: %s", url, fetchLastErrString); cleanup: + if (remote != NULL) + fclose(remote); close(fd); unlink(tmppkg); From owner-svn-src-head@FreeBSD.ORG Tue May 1 14:48:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8DF8C106566C; Tue, 1 May 2012 14:48:52 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 76AB88FC15; Tue, 1 May 2012 14:48:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41EmqVZ029839; Tue, 1 May 2012 14:48:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41Emp5t029823; Tue, 1 May 2012 14:48:51 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205011448.q41Emp5t029823@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 14:48:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234873 - in head/sys/dev/ath: . ath_hal ath_hal/ar5210 ath_hal/ar5211 ath_hal/ar5212 ath_hal/ar5416 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 14:48:52 -0000 Author: adrian Date: Tue May 1 14:48:51 2012 New Revision: 234873 URL: http://svn.freebsd.org/changeset/base/234873 Log: Change the MIB cycle count API to return HAL_BOOL, rather than uint32_t, to return whether it was successful. Add placeholder (blank) methods for previous chips, for both it and the 11n extension channel busy call. Modified: head/sys/dev/ath/ath_hal/ah.h head/sys/dev/ath/ath_hal/ar5210/ar5210.h head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c head/sys/dev/ath/ath_hal/ar5211/ar5211.h head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c head/sys/dev/ath/ath_hal/ar5212/ar5212.h head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c head/sys/dev/ath/ath_hal/ar5416/ar5416.h head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c head/sys/dev/ath/if_athvar.h Modified: head/sys/dev/ath/ath_hal/ah.h ============================================================================== --- head/sys/dev/ath/ath_hal/ah.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ah.h Tue May 1 14:48:51 2012 (r234873) @@ -1034,8 +1034,8 @@ struct ath_hal { struct ath_desc *); void __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *, struct ath_desc *, u_int); - uint32_t __ahdecl(*ah_get_mib_cycle_counts_pct) (struct ath_hal *, - uint32_t *, uint32_t *, uint32_t *, uint32_t *); + HAL_BOOL __ahdecl(*ah_getMibCycleCounts) (struct ath_hal *, + HAL_SURVEY_SAMPLE *); uint32_t __ahdecl(*ah_get11nExtBusy)(struct ath_hal *); void __ahdecl(*ah_set11nMac2040)(struct ath_hal *, Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5210/ar5210.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5210/ar5210.h Tue May 1 14:48:51 2012 (r234873) @@ -249,6 +249,9 @@ extern HAL_BOOL ar5210SetCapability(stru extern HAL_BOOL ar5210GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize); +extern uint32_t ar5210Get11nExtBusy(struct ath_hal *); +extern HAL_BOOL ar5210GetMibCycleCounts(struct ath_hal *, + HAL_SURVEY_SAMPLE *); extern u_int ar5210GetKeyCacheSize(struct ath_hal *); extern HAL_BOOL ar5210IsKeyCacheEntryValid(struct ath_hal *, uint16_t); Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5210/ar5210_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -129,8 +129,10 @@ static const struct ath_hal_private ar52 .ah_getAckCTSRate = ar5210GetAckCTSRate, .ah_setCTSTimeout = ar5210SetCTSTimeout, .ah_getCTSTimeout = ar5210GetCTSTimeout, - .ah_setDecompMask = ar5210SetDecompMask, - .ah_setCoverageClass = ar5210SetCoverageClass, + .ah_setDecompMask = ar5210SetDecompMask, + .ah_setCoverageClass = ar5210SetCoverageClass, + .ah_get11nExtBusy = ar5210Get11nExtBusy, + .ah_getMibCycleCounts = ar5210GetMibCycleCounts, /* Key Cache Functions */ .ah_getKeyCacheSize = ar5210GetKeyCacheSize, Modified: head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5210/ar5210_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -646,3 +646,24 @@ ar5210GetDiagState(struct ath_hal *ah, i return ath_hal_getdiagstate(ah, request, args, argsize, result, resultsize); } + +/* + * Return what percentage of the extension channel is busy. + * This is always disabled for AR5210 series NICs. + */ +uint32_t +ar5210Get11nExtBusy(struct ath_hal *ah) +{ + + return (0); +} + +/* + * There's no channel survey support for the AR5210. + */ +HAL_BOOL +ar5210GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) +{ + + return (AH_FALSE); +} Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5211/ar5211.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5211/ar5211.h Tue May 1 14:48:51 2012 (r234873) @@ -276,6 +276,9 @@ extern HAL_BOOL ar5211SetCapability(stru extern HAL_BOOL ar5211GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize); +extern uint32_t ar5211Get11nExtBusy(struct ath_hal *); +extern HAL_BOOL ar5211GetMibCycleCounts(struct ath_hal *, + HAL_SURVEY_SAMPLE *); extern u_int ar5211GetKeyCacheSize(struct ath_hal *); extern HAL_BOOL ar5211IsKeyCacheEntryValid(struct ath_hal *, uint16_t); Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5211/ar5211_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -129,8 +129,10 @@ static const struct ath_hal_private ar52 .ah_getAckCTSRate = ar5211GetAckCTSRate, .ah_setCTSTimeout = ar5211SetCTSTimeout, .ah_getCTSTimeout = ar5211GetCTSTimeout, - .ah_setDecompMask = ar5211SetDecompMask, - .ah_setCoverageClass = ar5211SetCoverageClass, + .ah_setDecompMask = ar5211SetDecompMask, + .ah_setCoverageClass = ar5211SetCoverageClass, + .ah_get11nExtBusy = ar5211Get11nExtBusy, + .ah_getMibCycleCounts = ar5211GetMibCycleCounts, /* Key Cache Functions */ .ah_getKeyCacheSize = ar5211GetKeyCacheSize, Modified: head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5211/ar5211_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -688,3 +688,24 @@ ar5211GetDiagState(struct ath_hal *ah, i } return AH_FALSE; } + +/* + * Return what percentage of the extension channel is busy. + * This is always disabled for AR5211 series NICs. + */ +uint32_t +ar5211Get11nExtBusy(struct ath_hal *ah) +{ + return (0); +} + + +/* + * There's no channel survey support for the AR5211. + */ +HAL_BOOL +ar5211GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) +{ + + return (AH_FALSE); +} Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212.h Tue May 1 14:48:51 2012 (r234873) @@ -511,6 +511,8 @@ extern HAL_BOOL ar5212GetDiagState(struc void **result, uint32_t *resultsize); extern HAL_STATUS ar5212SetQuiet(struct ath_hal *ah, uint32_t period, uint32_t duration, uint32_t nextStart, HAL_QUIET_FLAG flag); +extern HAL_BOOL ar5212GetMibCycleCounts(struct ath_hal *, + HAL_SURVEY_SAMPLE *); extern HAL_BOOL ar5212SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip); Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -125,9 +125,10 @@ static const struct ath_hal_private ar52 .ah_getAckCTSRate = ar5212GetAckCTSRate, .ah_setCTSTimeout = ar5212SetCTSTimeout, .ah_getCTSTimeout = ar5212GetCTSTimeout, - .ah_setDecompMask = ar5212SetDecompMask, - .ah_setCoverageClass = ar5212SetCoverageClass, + .ah_setDecompMask = ar5212SetDecompMask, + .ah_setCoverageClass = ar5212SetCoverageClass, .ah_setQuiet = ar5212SetQuiet, + .ah_getMibCycleCounts = ar5212GetMibCycleCounts, /* DFS Functions */ .ah_enableDfs = ar5212EnableDfs, Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -1248,3 +1248,13 @@ ar5212Get11nExtBusy(struct ath_hal *ah) { return 0; } + +/* + * There's no channel survey support for the AR5211. + */ +HAL_BOOL +ar5212GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) +{ + + return (AH_FALSE); +} Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h Tue May 1 14:48:51 2012 (r234873) @@ -196,8 +196,8 @@ extern uint32_t ar5416GetCurRssi(struct extern HAL_BOOL ar5416SetAntennaSwitch(struct ath_hal *, HAL_ANT_SETTING); extern HAL_BOOL ar5416SetDecompMask(struct ath_hal *, uint16_t, int); extern void ar5416SetCoverageClass(struct ath_hal *, uint8_t, int); -extern uint32_t ar5416GetMibCycleCounts(struct ath_hal *ah, - HAL_SURVEY_SAMPLE *hsample); +extern HAL_BOOL ar5416GetMibCycleCounts(struct ath_hal *ah, + HAL_SURVEY_SAMPLE *hsample); extern uint32_t ar5416Get11nExtBusy(struct ath_hal *ah); extern void ar5416Set11nMac2040(struct ath_hal *ah, HAL_HT_MACMODE mode); extern HAL_HT_RXCLEAR ar5416Get11nRxClear(struct ath_hal *ah); Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_ani.c Tue May 1 14:48:51 2012 (r234873) @@ -847,7 +847,7 @@ ar5416AniGetListenTime(struct ath_hal *a if (ANI_ENA(ah)) aniState = ahp->ah_curani; - if (good == 0) { + if (good == AH_FALSE) { /* * Cycle counter wrap (or initial call); it's not possible * to accurately calculate a value because the registers Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Tue May 1 14:48:51 2012 (r234873) @@ -145,6 +145,7 @@ ar5416InitState(struct ath_hal_5416 *ahp ah->ah_setDecompMask = ar5416SetDecompMask; ah->ah_setCoverageClass = ar5416SetCoverageClass; ah->ah_setQuiet = ar5416SetQuiet; + ah->ah_getMibCycleCounts = ar5416GetMibCycleCounts; ah->ah_resetKeyCacheEntry = ar5416ResetKeyCacheEntry; ah->ah_setKeyCacheEntry = ar5416SetKeyCacheEntry; Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c Tue May 1 14:48:51 2012 (r234873) @@ -184,11 +184,11 @@ ar5416SetCoverageClass(struct ath_hal *a /* * Return the busy for rx_frame, rx_clear, and tx_frame */ -uint32_t +HAL_BOOL ar5416GetMibCycleCounts(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hsample) { struct ath_hal_5416 *ahp = AH5416(ah); - u_int32_t good = 1; + u_int32_t good = AH_TRUE; /* XXX freeze/unfreeze mib counters */ uint32_t rc = OS_REG_READ(ah, AR_RCCNT); @@ -205,7 +205,7 @@ ar5416GetMibCycleCounts(struct ath_hal * */ HALDEBUG(ah, HAL_DEBUG_ANY, "%s: cycle counter wrap. ExtBusy = 0\n", __func__); - good = 0; + good = AH_FALSE; } else { hsample->cycle_count = cc - ahp->ah_cycleCount; hsample->chan_busy = rc - ahp->ah_ctlBusy; @@ -224,7 +224,7 @@ ar5416GetMibCycleCounts(struct ath_hal * ahp->ah_txBusy = tf; ahp->ah_extBusy = ec; - return good; + return (good); } /* Modified: head/sys/dev/ath/if_athvar.h ============================================================================== --- head/sys/dev/ath/if_athvar.h Tue May 1 11:45:16 2012 (r234872) +++ head/sys/dev/ath/if_athvar.h Tue May 1 14:48:51 2012 (r234873) @@ -1011,6 +1011,8 @@ void ath_intr(void *); ((*(_ah)->ah_isFastClockEnabled)((_ah))) #define ath_hal_radar_wait(_ah, _chan) \ ((*(_ah)->ah_radarWait)((_ah), (_chan))) +#define ath_hal_get_mib_cycle_counts(_ah, _sample) \ + ((*(_ah)->ah_getMibCycleCounts)((_ah), (_sample))) #define ath_hal_get_chan_ext_busy(_ah) \ ((*(_ah)->ah_get11nExtBusy)((_ah))) From owner-svn-src-head@FreeBSD.ORG Tue May 1 15:35:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA25B106566B; Tue, 1 May 2012 15:35:10 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C36C28FC08; Tue, 1 May 2012 15:35:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41FZA87032085; Tue, 1 May 2012 15:35:10 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FZAH1032079; Tue, 1 May 2012 15:35:10 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011535.q41FZAH1032079@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:35:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234874 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:35:10 -0000 Author: monthadar Date: Tue May 1 15:35:10 2012 New Revision: 234874 URL: http://svn.freebsd.org/changeset/base/234874 Log: Added Self-protected action category (including MPM). * Added new action category IEEE80211_ACTION_CAT_SELF_PROT which is used by 11s for Mesh Peering Management; * Updated Self protected enum Action codes to start from 1 instead of 0 according to the standard spec; * Removed old and wrong action categories IEEE80211_ACTION_CAT_MESHPEERING; * Modified ieee80211_mesh.c and ieee80211_action.c to use the new action category code; * Added earlier verification code in ieee80211_input; Approved by: adrian Modified: head/sys/net80211/ieee80211.h head/sys/net80211/ieee80211_action.c head/sys/net80211/ieee80211_input.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211.h ============================================================================== --- head/sys/net80211/ieee80211.h Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211.h Tue May 1 15:35:10 2012 (r234874) @@ -333,6 +333,8 @@ struct ieee80211_action { #define IEEE80211_ACTION_CAT_BA 3 /* BA */ #define IEEE80211_ACTION_CAT_HT 7 /* HT */ #define IEEE80211_ACTION_CAT_MESH 13 /* Mesh */ +#define IEEE80211_ACTION_CAT_SELF_PROT 15 /* Self-protected */ +/* 16 - 125 reserved */ #define IEEE80211_ACTION_CAT_VENDOR 127 /* Vendor Specific */ #define IEEE80211_ACTION_HT_TXCHWIDTH 0 /* recommended xmit chan width*/ Modified: head/sys/net80211/ieee80211_action.c ============================================================================== --- head/sys/net80211/ieee80211_action.c Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_action.c Tue May 1 15:35:10 2012 (r234874) @@ -94,7 +94,7 @@ ieee80211_send_action_register(int cat, break; ht_send_action[act] = f; return 0; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (act >= N(meshpl_send_action)) break; meshpl_send_action[act] = f; @@ -144,7 +144,7 @@ ieee80211_send_action(struct ieee80211_n if (act < N(ht_send_action)) f = ht_send_action[act]; break; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (act < N(meshpl_send_action)) f = meshpl_send_action[act]; break; @@ -215,7 +215,7 @@ ieee80211_recv_action_register(int cat, break; ht_recv_action[act] = f; return 0; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (act >= N(meshpl_recv_action)) break; meshpl_recv_action[act] = f; @@ -269,7 +269,7 @@ ieee80211_recv_action(struct ieee80211_n if (ia->ia_action < N(ht_recv_action)) f = ht_recv_action[ia->ia_action]; break; - case IEEE80211_ACTION_CAT_MESHPEERING: + case IEEE80211_ACTION_CAT_SELF_PROT: if (ia->ia_action < N(meshpl_recv_action)) f = meshpl_recv_action[ia->ia_action]; break; Modified: head/sys/net80211/ieee80211_input.c ============================================================================== --- head/sys/net80211/ieee80211_input.c Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_input.c Tue May 1 15:35:10 2012 (r234874) @@ -792,6 +792,24 @@ ieee80211_parse_action(struct ieee80211_ return EINVAL; } break; + case IEEE80211_ACTION_CAT_SELF_PROT: + /* If TA or RA group address discard silently */ + if (IEEE80211_IS_MULTICAST(wh->i_addr1) || + IEEE80211_IS_MULTICAST(wh->i_addr2)) + return EINVAL; + /* + * XXX: Should we verify complete length now or it is + * to varying in sizes? + */ + switch (ia->ia_action) { + case IEEE80211_ACTION_MESHPEERING_CONFIRM: + case IEEE80211_ACTION_MESHPEERING_CLOSE: + /* is not a peering candidate (yet) */ + if (ni == vap->iv_bss) + return EINVAL; + break; + } + break; #endif } return 0; Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:35:10 2012 (r234874) @@ -430,25 +430,25 @@ ieee80211_mesh_init(void) /* * Register action frame handlers. */ - ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_recv_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, mesh_recv_action_meshpeering_open); - ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_recv_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, mesh_recv_action_meshpeering_confirm); - ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_recv_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, mesh_recv_action_meshpeering_close); ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESH, IEEE80211_ACTION_MESH_LMETRIC, mesh_recv_action_meshlmetric); - ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_send_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, mesh_send_action_meshpeering_open); - ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_send_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, mesh_send_action_meshpeering_confirm); - ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESHPEERING, + ieee80211_send_action_register(IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, mesh_send_action_meshpeering_close); ieee80211_send_action_register(IEEE80211_ACTION_CAT_MESH, @@ -485,7 +485,7 @@ mesh_vdetach_peers(void *arg, struct iee args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); } @@ -1440,7 +1440,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENSNT); args[0] = ni->ni_mlpid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, args); ni->ni_mlrcnt = 0; mesh_peer_timeout_setup(ni); @@ -1602,7 +1602,7 @@ mesh_parse_meshpeering_action(struct iee memset(mp, 0, sizeof(*mp)); mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); /* NB: peer link ID is optional on these frames */ - if (subtype == IEEE80211_MESH_PEER_LINK_CLOSE && + if (subtype == IEEE80211_ACTION_MESHPEERING_CLOSE && mpie->peer_len == 8) { mp->peer_linkid = 0; mp->peer_rcode = LE_READ_2(&mpie->peer_linkid); @@ -1646,7 +1646,7 @@ mesh_parse_meshpeering_action(struct iee args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1689,13 +1689,13 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; /* Announce we're open too... */ ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, args); /* ...and confirm the link. */ args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); mesh_peer_timeout_setup(ni); @@ -1707,7 +1707,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = ni->ni_mlpid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1718,7 +1718,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); break; @@ -1728,7 +1728,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); /* NB: don't setup/clear any timeout */ @@ -1740,7 +1740,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, @@ -1753,7 +1753,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); mesh_peer_timeout_stop(ni); @@ -1764,7 +1764,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = ni->ni_mlpid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1774,7 +1774,7 @@ mesh_recv_action_meshpeering_open(struct args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CONFIRM, args); break; @@ -1783,7 +1783,7 @@ mesh_recv_action_meshpeering_open(struct args[1] = meshpeer->peer_llinkid; args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); break; @@ -1825,7 +1825,7 @@ mesh_recv_action_meshpeering_confirm(str args[1] = meshpeer->peer_llinkid; args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); break; @@ -1835,7 +1835,7 @@ mesh_recv_action_meshpeering_confirm(str args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1875,7 +1875,7 @@ mesh_recv_action_meshpeering_close(struc args[1] = ni->ni_mllid; args[2] = IEEE80211_REASON_MESH_CLOSE_RCVD; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -1991,7 +1991,7 @@ mesh_send_action_meshpeering_open(struct frm = ieee80211_add_xrates(frm, rs); frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshconf(frm, vap); - frm = ieee80211_add_meshpeer(frm, IEEE80211_MESH_PEER_LINK_OPEN, + frm = ieee80211_add_meshpeer(frm, IEEE80211_ACTION_MESHPEERING_OPEN, args[0], 0, 0); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); return mesh_send_action(ni, m); @@ -2059,7 +2059,7 @@ mesh_send_action_meshpeering_confirm(str frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshconf(frm, vap); frm = ieee80211_add_meshpeer(frm, - IEEE80211_MESH_PEER_LINK_CONFIRM, + IEEE80211_ACTION_MESHPEERING_CONFIRM, args[0], args[1], 0); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); return mesh_send_action(ni, m); @@ -2110,7 +2110,7 @@ mesh_send_action_meshpeering_close(struc ADDSHORT(frm, args[2]); /* reason code */ frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshpeer(frm, - IEEE80211_MESH_PEER_LINK_CLOSE, + IEEE80211_ACTION_MESHPEERING_CLOSE, args[0], args[1], args[2]); m->m_pkthdr.len = m->m_len = frm - mtod(m, uint8_t *); return mesh_send_action(ni, m); @@ -2234,7 +2234,7 @@ mesh_peer_timeout_cb(void *arg) args[0] = ni->ni_mlpid; args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); ni->ni_mlrcnt = 0; mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -2242,7 +2242,7 @@ mesh_peer_timeout_cb(void *arg) } else { args[0] = ni->ni_mlpid; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_OPEN, args); ni->ni_mlrcnt++; mesh_peer_timeout_backoff(ni); @@ -2253,7 +2253,7 @@ mesh_peer_timeout_cb(void *arg) args[0] = ni->ni_mlpid; args[2] = IEEE80211_REASON_MESH_CONFIRM_TIMEOUT; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPEERING, + IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, args); ni->ni_mlrcnt = 0; mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); @@ -2341,15 +2341,15 @@ mesh_verify_meshpeer(struct ieee80211vap meshpeer->peer_len > 10) return 1; switch (subtype) { - case IEEE80211_MESH_PEER_LINK_OPEN: + case IEEE80211_ACTION_MESHPEERING_OPEN: if (meshpeer->peer_len != 6) return 1; break; - case IEEE80211_MESH_PEER_LINK_CONFIRM: + case IEEE80211_ACTION_MESHPEERING_CONFIRM: if (meshpeer->peer_len != 8) return 1; break; - case IEEE80211_MESH_PEER_LINK_CLOSE: + case IEEE80211_ACTION_MESHPEERING_CLOSE: if (meshpeer->peer_len < 8) return 1; if (meshpeer->peer_len == 8 && meshpeer->peer_linkid != 0) @@ -2425,13 +2425,13 @@ ieee80211_add_meshpeer(uint8_t *frm, uin *frm++ = IEEE80211_ELEMID_MESHPEER; switch (subtype) { - case IEEE80211_MESH_PEER_LINK_OPEN: + case IEEE80211_ACTION_MESHPEERING_OPEN: *frm++ = 6; /* length */ memcpy(frm, meshpeerproto, 4); frm += 4; ADDSHORT(frm, localid); /* local ID */ break; - case IEEE80211_MESH_PEER_LINK_CONFIRM: + case IEEE80211_ACTION_MESHPEERING_CONFIRM: KASSERT(peerid != 0, ("sending peer confirm without peer id")); *frm++ = 8; /* length */ memcpy(frm, meshpeerproto, 4); @@ -2439,7 +2439,7 @@ ieee80211_add_meshpeer(uint8_t *frm, uin ADDSHORT(frm, localid); /* local ID */ ADDSHORT(frm, peerid); /* peer ID */ break; - case IEEE80211_MESH_PEER_LINK_CLOSE: + case IEEE80211_ACTION_MESHPEERING_CLOSE: if (peerid) *frm++ = 10; /* length */ else Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 14:48:51 2012 (r234873) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:35:10 2012 (r234874) @@ -149,13 +149,6 @@ struct ieee80211_meshpeer_ie { uint16_t peer_rcode; } __packed; -enum { - IEEE80211_MESH_PEER_LINK_OPEN = 0, - IEEE80211_MESH_PEER_LINK_CONFIRM = 1, - IEEE80211_MESH_PEER_LINK_CLOSE = 2, - /* values 3-255 are reserved */ -}; - /* Mesh Peering Management Protocol */ #define IEEE80211_MESH_PEER_PROTO_OUI 0x00, 0x0f, 0xac #define IEEE80211_MESH_PEER_PROTO_VALUE 0x2a @@ -331,9 +324,9 @@ struct ieee80211_meshpuc_ie { /* * 802.11s Action Frames + * XXX: these are wrong, and some of them should be + * under MESH category while PROXY is under MULTIHOP category. */ -#define IEEE80211_ACTION_CAT_MESHPEERING 30 /* XXX Linux */ -/* XXX: these need to be looked into */ #define IEEE80211_ACTION_CAT_INTERWORK 15 #define IEEE80211_ACTION_CAT_RESOURCE 16 #define IEEE80211_ACTION_CAT_PROXY 17 @@ -342,10 +335,11 @@ struct ieee80211_meshpuc_ie { * Mesh Peering Action codes. */ enum { - IEEE80211_ACTION_MESHPEERING_OPEN = 0, - IEEE80211_ACTION_MESHPEERING_CONFIRM = 1, - IEEE80211_ACTION_MESHPEERING_CLOSE = 2, - /* 3-255 reserved */ + /* 0 reserved */ + IEEE80211_ACTION_MESHPEERING_OPEN = 1, + IEEE80211_ACTION_MESHPEERING_CONFIRM = 2, + IEEE80211_ACTION_MESHPEERING_CLOSE = 3, + /* 4-255 reserved */ }; /* From owner-svn-src-head@FreeBSD.ORG Tue May 1 15:39:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B407F106566B; Tue, 1 May 2012 15:39:16 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EE2A8FC15; Tue, 1 May 2012 15:39:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41FdG8V032267; Tue, 1 May 2012 15:39:16 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FdG1A032264; Tue, 1 May 2012 15:39:16 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011539.q41FdG1A032264@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:39:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234875 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:39:16 -0000 Author: monthadar Date: Tue May 1 15:39:16 2012 New Revision: 234875 URL: http://svn.freebsd.org/changeset/base/234875 Log: Modified structure and code that handles Mesh peering management. * Old struct ieee80211_meshpeer_ie had wrong peer_proto field size; * Added IEEE80211_MPM_* size macros; * Created an enum for the Mesh Peering Protocol Identifier field according to the standard spec and removed old defines; * Abbreviated Handshake Protocol is not used by the standard anymore; * Modified mesh_verify_meshpeer to use IEEE80211_MPM_* macros for verification; * Modified mesh_parse_meshpeering_action to parse complete frame, also to parse it according to the standard spec; * Modified ieee80211_add_meshpeer to construct correct MPM frames according to the standard spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:35:10 2012 (r234874) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:39:16 2012 (r234875) @@ -1573,8 +1573,7 @@ mesh_recv_ctl(struct ieee80211_node *ni, } /* - * Parse meshpeering action ie's for open+confirm frames; the - * important bits are returned in the supplied structure. + * Parse meshpeering action ie's for open+confirm frames */ static const struct ieee80211_meshpeer_ie * mesh_parse_meshpeering_action(struct ieee80211_node *ni, @@ -1600,15 +1599,27 @@ mesh_parse_meshpeering_action(struct iee meshpeer = frm; mpie = (const struct ieee80211_meshpeer_ie *) frm; memset(mp, 0, sizeof(*mp)); + mp->peer_proto = LE_READ_2(&mpie->peer_proto); mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); - /* NB: peer link ID is optional on these frames */ - if (subtype == IEEE80211_ACTION_MESHPEERING_CLOSE && - mpie->peer_len == 8) { - mp->peer_linkid = 0; - mp->peer_rcode = LE_READ_2(&mpie->peer_linkid); - } else { - mp->peer_linkid = LE_READ_2(&mpie->peer_linkid); - mp->peer_rcode = LE_READ_2(&mpie->peer_rcode); + switch (subtype) { + case IEEE80211_ACTION_MESHPEERING_CONFIRM: + mp->peer_linkid = + LE_READ_2(&mpie->peer_linkid); + break; + case IEEE80211_ACTION_MESHPEERING_CLOSE: + /* NB: peer link ID is optional */ + if (mpie->peer_len == + (IEEE80211_MPM_BASE_SZ + 2)) { + mp->peer_linkid = 0; + mp->peer_rcode = + LE_READ_2(&mpie->peer_linkid); + } else { + mp->peer_linkid = + LE_READ_2(&mpie->peer_linkid); + mp->peer_rcode = + LE_READ_2(&mpie->peer_rcode); + } + break; } break; } @@ -2337,22 +2348,31 @@ mesh_verify_meshpeer(struct ieee80211vap const struct ieee80211_meshpeer_ie *meshpeer = (const struct ieee80211_meshpeer_ie *) ie; - if (meshpeer == NULL || meshpeer->peer_len < 6 || - meshpeer->peer_len > 10) + if (meshpeer == NULL || + meshpeer->peer_len < IEEE80211_MPM_BASE_SZ || + meshpeer->peer_len > IEEE80211_MPM_MAX_SZ) return 1; + if (meshpeer->peer_proto != IEEE80211_MPPID_MPM) { + IEEE80211_DPRINTF(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + "Only MPM protocol is supported (proto: 0x%02X)", + meshpeer->peer_proto); + return 1; + } switch (subtype) { case IEEE80211_ACTION_MESHPEERING_OPEN: - if (meshpeer->peer_len != 6) + if (meshpeer->peer_len != IEEE80211_MPM_BASE_SZ) return 1; break; case IEEE80211_ACTION_MESHPEERING_CONFIRM: - if (meshpeer->peer_len != 8) + if (meshpeer->peer_len != IEEE80211_MPM_BASE_SZ + 2) return 1; break; case IEEE80211_ACTION_MESHPEERING_CLOSE: - if (meshpeer->peer_len < 8) + if (meshpeer->peer_len < IEEE80211_MPM_BASE_SZ + 2) return 1; - if (meshpeer->peer_len == 8 && meshpeer->peer_linkid != 0) + if (meshpeer->peer_len == (IEEE80211_MPM_BASE_SZ + 2) && + meshpeer->peer_linkid != 0) return 1; if (meshpeer->peer_rcode == 0) return 1; @@ -2418,34 +2438,29 @@ uint8_t * ieee80211_add_meshpeer(uint8_t *frm, uint8_t subtype, uint16_t localid, uint16_t peerid, uint16_t reason) { - /* XXX change for AH */ - static const uint8_t meshpeerproto[4] = IEEE80211_MESH_PEER_PROTO; KASSERT(localid != 0, ("localid == 0")); *frm++ = IEEE80211_ELEMID_MESHPEER; switch (subtype) { case IEEE80211_ACTION_MESHPEERING_OPEN: - *frm++ = 6; /* length */ - memcpy(frm, meshpeerproto, 4); - frm += 4; - ADDSHORT(frm, localid); /* local ID */ + *frm++ = IEEE80211_MPM_BASE_SZ; /* length */ + ADDSHORT(frm, IEEE80211_MPPID_MPM); /* proto */ + ADDSHORT(frm, localid); /* local ID */ break; case IEEE80211_ACTION_MESHPEERING_CONFIRM: KASSERT(peerid != 0, ("sending peer confirm without peer id")); - *frm++ = 8; /* length */ - memcpy(frm, meshpeerproto, 4); - frm += 4; - ADDSHORT(frm, localid); /* local ID */ - ADDSHORT(frm, peerid); /* peer ID */ + *frm++ = IEEE80211_MPM_BASE_SZ + 2; /* length */ + ADDSHORT(frm, IEEE80211_MPPID_MPM); /* proto */ + ADDSHORT(frm, localid); /* local ID */ + ADDSHORT(frm, peerid); /* peer ID */ break; case IEEE80211_ACTION_MESHPEERING_CLOSE: if (peerid) - *frm++ = 10; /* length */ + *frm++ = IEEE80211_MPM_MAX_SZ; /* length */ else - *frm++ = 8; /* length */ - memcpy(frm, meshpeerproto, 4); - frm += 4; + *frm++ = IEEE80211_MPM_BASE_SZ + 2; /* length */ + ADDSHORT(frm, IEEE80211_MPPID_MPM); /* proto */ ADDSHORT(frm, localid); /* local ID */ if (peerid) ADDSHORT(frm, peerid); /* peer ID */ Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:35:10 2012 (r234874) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:39:16 2012 (r234875) @@ -140,25 +140,24 @@ struct ieee80211_meshcngst_ie { } __packed; /* Peer Link Management */ +#define IEEE80211_MPM_BASE_SZ (4) +#define IEEE80211_MPM_MAX_SZ (8) struct ieee80211_meshpeer_ie { uint8_t peer_ie; /* IEEE80211_ELEMID_MESHPEER */ uint8_t peer_len; - uint8_t peer_proto[4]; /* Peer Management Protocol */ + uint16_t peer_proto; /* Peer Management Protocol */ uint16_t peer_llinkid; /* Local Link ID */ uint16_t peer_linkid; /* Peer Link ID */ uint16_t peer_rcode; } __packed; -/* Mesh Peering Management Protocol */ -#define IEEE80211_MESH_PEER_PROTO_OUI 0x00, 0x0f, 0xac -#define IEEE80211_MESH_PEER_PROTO_VALUE 0x2a -#define IEEE80211_MESH_PEER_PROTO { IEEE80211_MESH_PEER_PROTO_OUI, \ - IEEE80211_MESH_PEER_PROTO_VALUE } -/* Abbreviated Handshake Protocol */ -#define IEEE80211_MESH_PEER_PROTO_AH_OUI 0x00, 0x0f, 0xac -#define IEEE80211_MESH_PEER_PROTO_AH_VALUE 0x2b -#define IEEE80211_MESH_PEER_PROTO_AH { IEEE80211_MESH_PEER_PROTO_AH_OUI, \ - IEEE80211_MESH_PEER_PROTO_AH_VALUE } +/* Mesh Peering Protocol Identifier field value */ +enum { + IEEE80211_MPPID_MPM = 0, /* Mesh peering management */ + IEEE80211_MPPID_AUTH_MPM = 1, /* Auth. mesh peering exchange */ + /* 2-65535 reserved */ +}; + #ifdef notyet /* Mesh Channel Switch Annoucement */ struct ieee80211_meshcsa_ie { From owner-svn-src-head@FreeBSD.ORG Tue May 1 15:42:41 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB1691065672; Tue, 1 May 2012 15:42:41 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B50248FC15; Tue, 1 May 2012 15:42:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41FgfTS032425; Tue, 1 May 2012 15:42:41 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41Fgf4P032422; Tue, 1 May 2012 15:42:41 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011542.q41Fgf4P032422@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:42:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234876 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:42:41 -0000 Author: monthadar Date: Tue May 1 15:42:41 2012 New Revision: 234876 URL: http://svn.freebsd.org/changeset/base/234876 Log: Fixed some MPM reason codes and max number of neighbors check * Added IEEE80211_MESH_MAX_NEIGHBORS and it is set to 15, same as before; * Modified mesh_parse_meshpeering_action to verify MPM frame and send correct reason code for when a frame is rejected according to standard spec; * Modified mesh_recv_action_meshpeering_* according to the standard spec; * Modified mesh_peer_timeout_cb to always send CLOSE frame when in CONFIRMRCV state according to the standard spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:39:16 2012 (r234875) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:42:41 2012 (r234876) @@ -1573,7 +1573,7 @@ mesh_recv_ctl(struct ieee80211_node *ni, } /* - * Parse meshpeering action ie's for open+confirm frames + * Parse meshpeering action ie's for MPM frames */ static const struct ieee80211_meshpeer_ie * mesh_parse_meshpeering_action(struct ieee80211_node *ni, @@ -1583,7 +1583,9 @@ mesh_parse_meshpeering_action(struct iee { struct ieee80211vap *vap = ni->ni_vap; const struct ieee80211_meshpeer_ie *mpie; + uint16_t args[3]; const uint8_t *meshid, *meshconf, *meshpeer; + uint8_t sendclose = 0; /* 1 = MPM frame rejected, close will be sent */ meshid = meshconf = meshpeer = NULL; while (efrm - frm > 1) { @@ -1599,6 +1601,7 @@ mesh_parse_meshpeering_action(struct iee meshpeer = frm; mpie = (const struct ieee80211_meshpeer_ie *) frm; memset(mp, 0, sizeof(*mp)); + mp->peer_len = mpie->peer_len; mp->peer_proto = LE_READ_2(&mpie->peer_proto); mp->peer_llinkid = LE_READ_2(&mpie->peer_llinkid); switch (subtype) { @@ -1627,22 +1630,46 @@ mesh_parse_meshpeering_action(struct iee } /* - * Verify the contents of the frame. Action frames with - * close subtype don't have a Mesh Configuration IE. - * If if fails validation, close the peer link. + * Verify the contents of the frame. + * If it fails validation, close the peer link. */ - KASSERT(meshpeer != NULL && - subtype != IEEE80211_ACTION_MESHPEERING_CLOSE, - ("parsing close action")); - - if (mesh_verify_meshid(vap, meshid) || - mesh_verify_meshpeer(vap, subtype, meshpeer) || - mesh_verify_meshconf(vap, meshconf)) { - uint16_t args[3]; + if (mesh_verify_meshpeer(vap, subtype, (const uint8_t *)mp)) { + sendclose = 1; + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "MPM validation failed"); + } + /* If meshid is not the same reject any frames type. */ + if (sendclose == 0 && mesh_verify_meshid(vap, meshid)) { + sendclose = 1; IEEE80211_DISCARD(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, wh, NULL, "%s", "not for our mesh"); + if (subtype == IEEE80211_ACTION_MESHPEERING_CLOSE) { + /* + * Standard not clear about this, if we dont ignore + * there will be an endless loop between nodes sending + * CLOSE frames between each other with wrong meshid. + * Discard and timers will bring FSM to IDLE state. + */ + return NULL; + } + } + + /* + * Close frames are accepted if meshid is the same. + * Verify the other two types. + */ + if (sendclose == 0 && subtype != IEEE80211_ACTION_MESHPEERING_CLOSE && + mesh_verify_meshconf(vap, meshconf)) { + sendclose = 1; + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "configuration missmatch"); + } + + if (sendclose) { vap->iv_stats.is_rx_mgtdiscard++; switch (ni->ni_mlstate) { case IEEE80211_NODE_MESH_IDLE: @@ -1655,7 +1682,15 @@ mesh_parse_meshpeering_action(struct iee case IEEE80211_NODE_MESH_CONFIRMRCV: args[0] = ni->ni_mlpid; args[1] = ni->ni_mllid; - args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; + /* Reason codes for rejection */ + switch (subtype) { + case IEEE80211_ACTION_MESHPEERING_OPEN: + args[2] = IEEE80211_REASON_MESH_CPVIOLATION; + break; + case IEEE80211_ACTION_MESHPEERING_CONFIRM: + args[2] = IEEE80211_REASON_MESH_INCONS_PARAMS; + break; + } ieee80211_send_action(ni, IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -1666,6 +1701,7 @@ mesh_parse_meshpeering_action(struct iee } return NULL; } + return (const struct ieee80211_meshpeer_ie *) mp; } @@ -1675,6 +1711,7 @@ mesh_recv_action_meshpeering_open(struct const uint8_t *frm, const uint8_t *efrm) { struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_meshpeer_ie ie; const struct ieee80211_meshpeer_ie *meshpeer; uint16_t args[3]; @@ -1692,6 +1729,19 @@ mesh_recv_action_meshpeering_open(struct switch (ni->ni_mlstate) { case IEEE80211_NODE_MESH_IDLE: + /* Reject open request if reached our maximum neighbor count */ + if (ms->ms_neighbors >= IEEE80211_MESH_MAX_NEIGHBORS) { + args[0] = meshpeer->peer_llinkid; + args[1] = 0; + args[2] = IEEE80211_REASON_MESH_MAX_PEERS; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_SELF_PROT, + IEEE80211_ACTION_MESHPEERING_CLOSE, + args); + /* stay in IDLE state */ + return (0); + } + /* Open frame accepted */ mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENRCV); ni->ni_mllid = meshpeer->peer_llinkid; ni->ni_mlpid = mesh_generateid(vap); @@ -1792,7 +1842,8 @@ mesh_recv_action_meshpeering_open(struct case IEEE80211_NODE_MESH_HOLDING: args[0] = ni->ni_mlpid; args[1] = meshpeer->peer_llinkid; - args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; + /* Standard not clear about what the reaason code should be */ + args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -1830,11 +1881,13 @@ mesh_recv_action_meshpeering_confirm(str break; case IEEE80211_NODE_MESH_OPENSNT: mesh_linkchange(ni, IEEE80211_NODE_MESH_CONFIRMRCV); + mesh_peer_timeout_setup(ni); break; case IEEE80211_NODE_MESH_HOLDING: args[0] = ni->ni_mlpid; args[1] = meshpeer->peer_llinkid; - args[2] = IEEE80211_REASON_MESH_MAX_RETRIES; + /* Standard not clear about what the reaason code should be */ + args[2] = IEEE80211_REASON_PEER_LINK_CANCELED; ieee80211_send_action(ni, IEEE80211_ACTION_CAT_SELF_PROT, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -1869,8 +1922,23 @@ mesh_recv_action_meshpeering_close(struc const struct ieee80211_frame *wh, const uint8_t *frm, const uint8_t *efrm) { + struct ieee80211_meshpeer_ie ie; + const struct ieee80211_meshpeer_ie *meshpeer; uint16_t args[3]; + /* +2 for action + code */ + meshpeer = mesh_parse_meshpeering_action(ni, wh, frm+2, efrm, &ie, + IEEE80211_ACTION_MESHPEERING_CLOSE); + if (meshpeer == NULL) { + return 0; + } + + /* + * XXX: check reason code, for example we could receive + * IEEE80211_REASON_MESH_MAX_PEERS then we should not attempt + * to peer again. + */ + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, ni, "%s", "recv PEER CLOSE"); @@ -1894,7 +1962,7 @@ mesh_recv_action_meshpeering_close(struc break; case IEEE80211_NODE_MESH_HOLDING: mesh_linkchange(ni, IEEE80211_NODE_MESH_IDLE); - mesh_peer_timeout_setup(ni); + mesh_peer_timeout_stop(ni); break; } return 0; @@ -2112,13 +2180,11 @@ mesh_send_action_meshpeering_close(struc * mesh peer close action frame format: * [1] category * [1] action - * [2] reason code * [tlv] mesh id * [tlv] mesh peer link mgmt */ *frm++ = category; *frm++ = action; - ADDSHORT(frm, args[2]); /* reason code */ frm = ieee80211_add_meshid(frm, vap); frm = ieee80211_add_meshpeer(frm, IEEE80211_ACTION_MESHPEERING_CLOSE, @@ -2260,19 +2326,13 @@ mesh_peer_timeout_cb(void *arg) } break; case IEEE80211_NODE_MESH_CONFIRMRCV: - if (ni->ni_mlrcnt == ieee80211_mesh_maxretries) { - args[0] = ni->ni_mlpid; - args[2] = IEEE80211_REASON_MESH_CONFIRM_TIMEOUT; - ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_SELF_PROT, - IEEE80211_ACTION_MESHPEERING_CLOSE, args); - ni->ni_mlrcnt = 0; - mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); - mesh_peer_timeout_setup(ni); - } else { - ni->ni_mlrcnt++; - mesh_peer_timeout_setup(ni); - } + args[0] = ni->ni_mlpid; + args[2] = IEEE80211_REASON_MESH_CONFIRM_TIMEOUT; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_SELF_PROT, + IEEE80211_ACTION_MESHPEERING_CLOSE, args); + mesh_linkchange(ni, IEEE80211_NODE_MESH_HOLDING); + mesh_peer_timeout_setup(ni); break; case IEEE80211_NODE_MESH_HOLDING: mesh_linkchange(ni, IEEE80211_NODE_MESH_IDLE); @@ -2418,7 +2478,8 @@ ieee80211_add_meshconf(uint8_t *frm, str *frm++ = IEEE80211_MESHCONF_SYNC_NEIGHOFF; *frm++ = IEEE80211_MESHCONF_AUTH_DISABLED; /* NB: set the number of neighbors before the rest */ - *frm = (ms->ms_neighbors > 15 ? 15 : ms->ms_neighbors) << 1; + *frm = (ms->ms_neighbors > IEEE80211_MESH_MAX_NEIGHBORS ? + IEEE80211_MESH_MAX_NEIGHBORS : ms->ms_neighbors) << 1; if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) *frm |= IEEE80211_MESHCONF_FORM_MP; frm += 1; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:39:16 2012 (r234875) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:42:41 2012 (r234876) @@ -32,6 +32,7 @@ #define _NET80211_IEEE80211_MESH_H_ #define IEEE80211_MESH_DEFAULT_TTL 31 +#define IEEE80211_MESH_MAX_NEIGHBORS 15 /* * NB: all structures are __packed so sizeof works on arm, et. al. From owner-svn-src-head@FreeBSD.ORG Tue May 1 15:47:31 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6EAC8106564A; Tue, 1 May 2012 15:47:31 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 589DC8FC0A; Tue, 1 May 2012 15:47:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41FlVbA032644; Tue, 1 May 2012 15:47:31 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FlVbJ032639; Tue, 1 May 2012 15:47:31 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011547.q41FlVbJ032639@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:47:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234877 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:47:31 -0000 Author: monthadar Date: Tue May 1 15:47:30 2012 New Revision: 234877 URL: http://svn.freebsd.org/changeset/base/234877 Log: Implemented so that Mesh forwarding information lifetime is dynamic. * Introduced ieee80211_mesh_rt_update that updates a route with the maximum(lifetime left, new lifetime); * Modified ieee80211_mesh_route struct by adding a lock that will be used by both ieee80211_mesh_rt_update and precursor code (added in future commit); * Modified in ieee80211_hwmp.c HWMP code to use new ieee80211_mesh_rt_update; * Modified mesh_rt_flush_invalid to use new ieee80211_mesh_rt_update; * mesh_rt_flush also checks that lifetime == 0, this gives route discovery a change to complete; * Modified mesh_recv_mgmt case IEEE80211_FC0_SUBTYPE_BEACON: when ever we received a beacon from a neighbor we update route lifetime; Approved by: adrian Modified: head/sys/net80211/ieee80211_ddb.c head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_ddb.c Tue May 1 15:47:30 2012 (r234877) @@ -870,8 +870,10 @@ _db_show_mesh(const struct ieee80211_mes TAILQ_FOREACH(rt, &ms->ms_routes, rt_next) { db_printf("entry %d:\tdest: %6D nexthop: %6D metric: %u", i, rt->rt_dest, ":", rt->rt_nexthop, ":", rt->rt_metric); + db_printf("\tlifetime: %u lastseq: %u priv: %p\n", - rt->rt_lifetime, rt->rt_lastmseq, rt->rt_priv); + ieee80211_mesh_rt_update(rt, 0), + rt->rt_lastmseq, rt->rt_priv); i++; } } Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:47:30 2012 (r234877) @@ -143,9 +143,6 @@ typedef uint32_t ieee80211_hwmp_seq; #define HWMP_SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) #define HWMP_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) -/* The longer one of the lifetime should be stored as new lifetime */ -#define MESH_ROUTE_LIFETIME_MAX(a, b) (a > b ? a : b) - /* * Private extension of ieee80211_mesh_route. */ @@ -938,7 +935,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* Data creation and update of forwarding information * according to Table 11C-8 for originator mesh STA. */ - if(HWMP_SEQ_GT(preq->preq_origseq, hrorig->hr_seq) || + if (HWMP_SEQ_GT(preq->preq_origseq, hrorig->hr_seq) || (HWMP_SEQ_EQ(preq->preq_origseq, hrorig->hr_seq) && preq->preq_metric < rtorig->rt_metric)) { hrorig->hr_seq = preq->preq_origseq; @@ -946,8 +943,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, rtorig->rt_metric = preq->preq_metric + ms->ms_pmetric->mpm_metric(ni); rtorig->rt_nhops = preq->preq_hopcount + 1; - rtorig->rt_lifetime = MESH_ROUTE_LIFETIME_MAX( - preq->preq_lifetime, rtorig->rt_lifetime); + ieee80211_mesh_rt_update(rtorig, preq->preq_lifetime); /* path to orig is valid now */ rtorig->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; }else if(hrtarg != NULL && @@ -1124,7 +1120,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, } } rt->rt_metric = preq->preq_metric; - rt->rt_lifetime = preq->preq_lifetime; + ieee80211_mesh_rt_update(rt, preq->preq_lifetime); hrorig = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); hrorig->hr_seq = preq->preq_origseq; @@ -1221,7 +1217,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, } IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); rt->rt_nhops = prep->prep_hopcount; - rt->rt_lifetime = prep->prep_lifetime; + ieee80211_mesh_rt_update(rt, prep->prep_lifetime); rt->rt_metric = prep->prep_metric; rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1300,7 +1296,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric, prep->prep_metric); IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); rt->rt_nhops = prep->prep_hopcount + 1; - rt->rt_lifetime = prep->prep_lifetime; + ieee80211_mesh_rt_update(rt, prep->prep_lifetime); rt->rt_metric = metric; rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; } else { @@ -1594,8 +1590,9 @@ hwmp_discover(struct ieee80211vap *vap, if (hr->hr_origseq == 0) hr->hr_origseq = ++hs->hs_seq; rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; - rt->rt_lifetime = - ticks_to_msecs(ieee80211_hwmp_pathtimeout); + /* XXX: special discovery timeout, larger lifetime? */ + ieee80211_mesh_rt_update(rt, + ticks_to_msecs(ieee80211_hwmp_pathtimeout)); /* XXX check preq retries */ sendpreq = 1; IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest, @@ -1613,7 +1610,8 @@ hwmp_discover(struct ieee80211vap *vap, preq.preq_id = ++hs->hs_preqid; IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); preq.preq_origseq = hr->hr_origseq; - preq.preq_lifetime = rt->rt_lifetime; + preq.preq_lifetime = + ticks_to_msecs(ieee80211_hwmp_pathtimeout); preq.preq_metric = rt->rt_metric; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest); Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:47:30 2012 (r234877) @@ -138,6 +138,10 @@ static const struct ieee80211_mesh_proto static struct ieee80211_mesh_proto_path mesh_proto_paths[4]; static struct ieee80211_mesh_proto_metric mesh_proto_metrics[4]; +#define RT_ENTRY_LOCK(rt) mtx_lock(&(rt)->rt_lock) +#define RT_ENTRY_LOCK_ASSERT(rt) mtx_assert(&(rt)->rt_lock, MA_OWNED) +#define RT_ENTRY_UNLOCK(rt) mtx_unlock(&(rt)->rt_lock) + #define MESH_RT_LOCK(ms) mtx_lock(&(ms)->ms_rt_lock) #define MESH_RT_LOCK_ASSERT(ms) mtx_assert(&(ms)->ms_rt_lock, MA_OWNED) #define MESH_RT_UNLOCK(ms) mtx_unlock(&(ms)->ms_rt_lock) @@ -146,6 +150,9 @@ MALLOC_DEFINE(M_80211_MESH_PREQ, "80211p MALLOC_DEFINE(M_80211_MESH_PREP, "80211prep", "802.11 MESH Path Reply frame"); MALLOC_DEFINE(M_80211_MESH_PERR, "80211perr", "802.11 MESH Path Error frame"); +/* The longer one of the lifetime should be stored as new lifetime */ +#define MESH_ROUTE_LIFETIME_MAX(a, b) (a > b ? a : b) + MALLOC_DEFINE(M_80211_MESH_RT, "80211mesh", "802.11s routing table"); /* @@ -183,7 +190,8 @@ mesh_rt_add_locked(struct ieee80211_mesh if (rt != NULL) { IEEE80211_ADDR_COPY(rt->rt_dest, dest); rt->rt_priv = (void *)ALIGN(&rt[1]); - rt->rt_crtime = ticks; + mtx_init(&rt->rt_lock, "MBSS_RT", "802.11s route entry", MTX_DEF); + rt->rt_updtime = ticks; /* create time */ TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next); } return rt; @@ -221,6 +229,41 @@ ieee80211_mesh_rt_add(struct ieee80211va } /* + * Update the route lifetime and returns the updated lifetime. + * If new_lifetime is zero and route is timedout it will be invalidated. + * new_lifetime is in msec + */ +int +ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int new_lifetime) +{ + int timesince, now; + uint32_t lifetime = 0; + + now = ticks; + RT_ENTRY_LOCK(rt); + timesince = ticks_to_msecs(now - rt->rt_updtime); + rt->rt_updtime = now; + if (timesince >= rt->rt_lifetime) { + if (new_lifetime != 0) { + rt->rt_lifetime = new_lifetime; + } + else { + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_VALID; + rt->rt_lifetime = 0; + } + } else { + /* update what is left of lifetime */ + rt->rt_lifetime = rt->rt_lifetime - timesince; + rt->rt_lifetime = MESH_ROUTE_LIFETIME_MAX( + new_lifetime, rt->rt_lifetime); + } + lifetime = rt->rt_lifetime; + RT_ENTRY_UNLOCK(rt); + + return lifetime; +} + +/* * Add a proxy route (as needed) for the specified destination. */ void @@ -271,6 +314,12 @@ static __inline void mesh_rt_del(struct ieee80211_mesh_state *ms, struct ieee80211_mesh_route *rt) { TAILQ_REMOVE(&ms->ms_routes, rt, rt_next); + /* + * Grab the lock before destroying it, to be sure no one else + * is holding the route. + */ + RT_ENTRY_LOCK(rt); + mtx_destroy(&rt->rt_lock); free(rt, M_80211_MESH_RT); } @@ -335,8 +384,13 @@ mesh_rt_flush_invalid(struct ieee80211va return; MESH_RT_LOCK(ms); TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) { + ieee80211_mesh_rt_update(rt, 0); + /* + * NB: we check for lifetime == 0 so that we give a chance + * for route discovery to complete. + */ if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 && - ticks - rt->rt_crtime >= ms->ms_ppath->mpp_inact) + rt->rt_lifetime == 0) mesh_rt_del(ms, rt); } MESH_RT_UNLOCK(ms); @@ -1338,6 +1392,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211com *ic = ni->ni_ic; struct ieee80211_frame *wh; + struct ieee80211_mesh_route *rt; uint8_t *frm, *efrm; wh = mtod(m0, struct ieee80211_frame *); @@ -1430,20 +1485,40 @@ mesh_recv_mgmt(struct ieee80211_node *ni * XXX backoff on repeated failure */ if (ni != vap->iv_bss && - (ms->ms_flags & IEEE80211_MESHFLAGS_AP) && - ni->ni_mlstate == IEEE80211_NODE_MESH_IDLE) { - uint16_t args[1]; - - ni->ni_mlpid = mesh_generateid(vap); - if (ni->ni_mlpid == 0) - return; - mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENSNT); - args[0] = ni->ni_mlpid; - ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_SELF_PROT, - IEEE80211_ACTION_MESHPEERING_OPEN, args); - ni->ni_mlrcnt = 0; - mesh_peer_timeout_setup(ni); + (ms->ms_flags & IEEE80211_MESHFLAGS_AP)) { + switch (ni->ni_mlstate) { + case IEEE80211_NODE_MESH_IDLE: + { + uint16_t args[1]; + + ni->ni_mlpid = mesh_generateid(vap); + if (ni->ni_mlpid == 0) + return; + mesh_linkchange(ni, IEEE80211_NODE_MESH_OPENSNT); + args[0] = ni->ni_mlpid; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_SELF_PROT, + IEEE80211_ACTION_MESHPEERING_OPEN, args); + ni->ni_mlrcnt = 0; + mesh_peer_timeout_setup(ni); + break; + } + case IEEE80211_NODE_MESH_ESTABLISHED: + { + /* + * Valid beacon from a peer mesh STA + * bump TA lifetime + */ + rt = ieee80211_mesh_rt_find(vap, wh->i_addr2); + if(rt != NULL) { + ieee80211_mesh_rt_update(rt, + ms->ms_ppath->mpp_inact); + } + break; + } + default: + break; /* ignore */ + } } break; } @@ -2701,15 +2776,16 @@ mesh_ioctl_get80211(struct ieee80211vap break; imr = (struct ieee80211req_mesh_route *) (p + off); - imr->imr_flags = rt->rt_flags; IEEE80211_ADDR_COPY(imr->imr_dest, rt->rt_dest); IEEE80211_ADDR_COPY(imr->imr_nexthop, rt->rt_nexthop); imr->imr_metric = rt->rt_metric; imr->imr_nhops = rt->rt_nhops; - imr->imr_lifetime = rt->rt_lifetime; + imr->imr_lifetime = + ieee80211_mesh_rt_update(rt, 0); imr->imr_lastmseq = rt->rt_lastmseq; + imr->imr_flags = rt->rt_flags; /* last */ off += sizeof(*imr); } MESH_RT_UNLOCK(ms); Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:42:41 2012 (r234876) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:47:30 2012 (r234877) @@ -409,9 +409,19 @@ MALLOC_DECLARE(M_80211_MESH_PREP); MALLOC_DECLARE(M_80211_MESH_PERR); MALLOC_DECLARE(M_80211_MESH_RT); +/* + * Basic forwarding information: + * o Destination MAC + * o Next-hop MAC + * o Precursor list (not implemented yet) + * o Path timeout + * The rest is part of the active Mesh path selection protocol. + * XXX: to be moved out later. + */ struct ieee80211_mesh_route { TAILQ_ENTRY(ieee80211_mesh_route) rt_next; - int rt_crtime; /* creation time */ + struct mtx rt_lock; /* fine grained route lock */ + int rt_updtime; /* last update time */ uint8_t rt_dest[IEEE80211_ADDR_LEN]; uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; uint32_t rt_metric; /* path metric */ @@ -419,7 +429,7 @@ struct ieee80211_mesh_route { uint16_t rt_flags; #define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* patch discovery complete */ #define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ - uint32_t rt_lifetime; + uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ void *rt_priv; /* private data */ }; @@ -508,6 +518,7 @@ void ieee80211_mesh_rt_del(struct ieee8 void ieee80211_mesh_rt_flush(struct ieee80211vap *); void ieee80211_mesh_rt_flush_peer(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); +int ieee80211_mesh_rt_update(struct ieee80211_mesh_route *rt, int); void ieee80211_mesh_proxy_check(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); From owner-svn-src-head@FreeBSD.ORG Tue May 1 15:56:27 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31C79106566C; Tue, 1 May 2012 15:56:27 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1BB528FC16; Tue, 1 May 2012 15:56:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41FuRQC032998; Tue, 1 May 2012 15:56:27 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FuQP5032993; Tue, 1 May 2012 15:56:26 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011556.q41FuQP5032993@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:56:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234878 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:56:27 -0000 Author: monthadar Date: Tue May 1 15:56:26 2012 New Revision: 234878 URL: http://svn.freebsd.org/changeset/base/234878 Log: Mesh forwarding with proxy support. * Modified HWMP PREP/PREQ to contain a proxy entry and also changed PREP frame processing according to amendment as following: o Fixed PREP to always update/create if acceptance criteria is meet; o PREQ processing to reply if request is for a proxy entry that is proxied by us; o Removed hwmp_discover call from PREQ, because sending a PREP will build the forward path, and by receving and accepting a PREQ we have already built the reverse path (non-proactive code); * Disabled code for pro-active in PREP for now (will make a separate patch for pro-active HWMP routing later) * Added proxy information for a Mesh route, mesh gate to use and proxy seqno; * Modified ieee80211_encap according to amendment; * Introduced Mesh control address extension enum and removed unused struct, also rename some structure element names. * Modified mesh_input and added mesh_recv_* that should verify and process mesh data frames according to 9.32 Mesh forwarding framework in amendment; * Modified mesh_decap accordingly to changes done in mesh control AE struct; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 15:56:26 2012 (r234878) @@ -143,6 +143,8 @@ typedef uint32_t ieee80211_hwmp_seq; #define HWMP_SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) #define HWMP_SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) +#define HWMP_SEQ_MAX(a, b) (a > b ? a : b) + /* * Private extension of ieee80211_mesh_route. */ @@ -866,7 +868,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, const struct ieee80211_frame *wh, const struct ieee80211_meshpreq_ie *preq) { struct ieee80211_mesh_state *ms = vap->iv_mesh; - struct ieee80211_mesh_route *rt = NULL; + struct ieee80211_mesh_route *rt = NULL; /* pro-active code */ struct ieee80211_mesh_route *rtorig = NULL; struct ieee80211_mesh_route *rttarg = NULL; struct ieee80211_hwmp_route *hrorig = NULL; @@ -963,31 +965,44 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* * Check if the PREQ is addressed to us. + * or a Proxy currently supplied by us. */ - if (IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0))) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "reply to %6D", preq->preq_origaddr, ":"); + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) || + (rttarg != NULL && + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY && + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { /* - * Build and send a PREP frame. + * When we are the target we shall update our own HWMP seq + * number with max of (current and preq->seq) + 1 */ + hs->hs_seq = HWMP_SEQ_MAX(hs->hs_seq, PREQ_TSEQ(0)) + 1; + prep.prep_flags = 0; + if (rttarg != NULL && /* if NULL it means we are the target */ + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "reply for proxy %6D", rttarg->rt_dest, ":"); + prep.prep_flags |= IEEE80211_MESHPREP_FLAGS_AE; + IEEE80211_ADDR_COPY(prep.prep_target_ext_addr, + rttarg->rt_dest); + /* update proxy seqno to HWMP seqno */ + rttarg->rt_ext_seq = hs->hs_seq; + } + /* + * Build and send a PREP frame. + */ prep.prep_hopcount = 0; prep.prep_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(prep.prep_targetaddr, vap->iv_myaddr); - prep.prep_targetseq = ++hs->hs_seq; + prep.prep_targetseq = hs->hs_seq; prep.prep_lifetime = preq->preq_lifetime; prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL; IEEE80211_ADDR_COPY(prep.prep_origaddr, preq->preq_origaddr); prep.prep_origseq = preq->preq_origseq; + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "reply to %6D", preq->preq_origaddr, ":"); hwmp_send_prep(ni, vap->iv_myaddr, wh->i_addr2, &prep); - /* - * Build the reverse path, if we don't have it already. - */ - rt = ieee80211_mesh_rt_find(vap, preq->preq_origaddr); - if (rt == NULL) - hwmp_discover(vap, preq->preq_origaddr, NULL); - else if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) - hwmp_discover(vap, rt->rt_dest, NULL); return; } /* @@ -1179,15 +1194,19 @@ hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_mesh_route *rt = NULL; + struct ieee80211_mesh_route *rtorig = NULL; + struct ieee80211_mesh_route *rtext = NULL; struct ieee80211_hwmp_route *hr; struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; struct mbuf *m, *next; uint32_t metric = 0; + const uint8_t *addr; /* - * Acceptance criteria: if the corresponding PREQ was not generated - * by us and forwarding is disabled, discard this PREP. + * Acceptance criteria: If the corresponding PREP was not generated + * by us or generated by an external mac that is proxied by us + * and forwarding is disabled, discard this PREP. */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) @@ -1195,10 +1214,21 @@ hwmp_recv_prep(struct ieee80211vap *vap, if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) return; + rtorig = ieee80211_mesh_rt_find(vap, prep->prep_origaddr); + if (rtorig != NULL && + !(rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY)) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP(%u) for an orig(%6D) not proxied by us", + prep->prep_origseq, prep->prep_origaddr, ":"); + return; + } + + /* PREP ACCEPTED */ IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "received PREP from %6D", prep->prep_targetaddr, ":"); +#if 0 rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr); if (rt == NULL) { /* @@ -1228,10 +1258,30 @@ hwmp_recv_prep(struct ieee80211vap *vap, } return; } +#endif + /* - * Sequence number validation. + * If accepted shall create or update the active forwarding information + * it maintains for the target mesh STA of the PREP (according to the + * rules defined in 13.10.8.4). If the conditions for creating or + * updating the forwarding information have not been met in those + * rules, no further steps are applied to the PREP. + * [OPTIONAL]: update forwarding information to TA if metric improves. */ + rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr); + if (rt == NULL) { + rt = ieee80211_mesh_rt_add(vap, prep->prep_targetaddr); + if (rt == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add PREP path to %6D", + prep->prep_targetaddr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } + } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + /* update path metric */ + metric = prep->prep_metric + ms->ms_pmetric->mpm_metric(ni); if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { if (HWMP_SEQ_LT(prep->prep_targetseq, hr->hr_seq)) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1240,7 +1290,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, prep->prep_targetseq, hr->hr_seq); return; } else if (HWMP_SEQ_LEQ(prep->prep_targetseq, hr->hr_seq) && - prep->prep_metric > rt->rt_metric) { + metric > rt->rt_metric) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "discard PREP from %6D, new metric %u > %u", prep->prep_targetaddr, ":", @@ -1249,7 +1299,21 @@ hwmp_recv_prep(struct ieee80211vap *vap, } } + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "%s path to %6D, hopcount %d:%d metric %d:%d", + rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", + prep->prep_targetaddr, ":", + rt->rt_nhops, prep->prep_hopcount, + rt->rt_metric, metric); + hr->hr_seq = prep->prep_targetseq; + IEEE80211_ADDR_COPY(rt->rt_nexthop, ni->ni_macaddr); + rt->rt_metric = metric; + rt->rt_nhops = prep->prep_hopcount + 1; + ieee80211_mesh_rt_update(rt, prep->prep_lifetime); + rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ + /* * If it's NOT for us, propagate the PREP. */ @@ -1265,53 +1329,45 @@ hwmp_recv_prep(struct ieee80211vap *vap, pprep.prep_ttl -= 1; pprep.prep_metric += ms->ms_pmetric->mpm_metric(ni); hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr, &pprep); + + /* may store target external address if recevied PREP w/ AE */ + /* precursor list for the Target Mesh STA Address is updated */ } - hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); - if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { - /* NB: never clobber a proxy entry */; - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "discard PREP for %6D, route is marked PROXY", - prep->prep_targetaddr, ":"); - vap->iv_stats.is_hwmp_proxy++; - /* NB: first path discovery always fails */ - } else if (hr->hr_origseq == 0 || - prep->prep_origseq == hr->hr_origseq) { - /* - * Check if we already have a path to this node. - * If we do, check if this path reply contains a - * better route. - */ - if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 || - (prep->prep_hopcount < rt->rt_nhops || - prep->prep_metric < rt->rt_metric)) { - hr->hr_origseq = prep->prep_origseq; - metric = prep->prep_metric + - ms->ms_pmetric->mpm_metric(ni); - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "%s path to %6D, hopcount %d:%d metric %d:%d", - rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? - "prefer" : "update", - prep->prep_origaddr, ":", - rt->rt_nhops, prep->prep_hopcount, - rt->rt_metric, prep->prep_metric); - IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); - rt->rt_nhops = prep->prep_hopcount + 1; - ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_metric = metric; - rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; - } else { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "ignore PREP for %6D, hopcount %d:%d metric %d:%d", - prep->prep_targetaddr, ":", - rt->rt_nhops, prep->prep_hopcount, - rt->rt_metric, prep->prep_metric); + /* check if we received a PREP for a proxy address */ + else if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { + rtext = ieee80211_mesh_rt_find(vap, + prep->prep_target_ext_addr); + if (rtext == NULL) { + rtext = ieee80211_mesh_rt_add(vap, + prep->prep_target_ext_addr); + if (rtext == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add PREP path to proxy %6D", + prep->prep_targetaddr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } } - } else { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "discard PREP for %6D, wrong orig seqno %u != %u", - prep->prep_targetaddr, ":", prep->prep_origseq, - hr->hr_origseq); - vap->iv_stats.is_hwmp_wrongseq++; + "%s path to %6D, hopcount %d:%d metric %d:%d", + rtext->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", + prep->prep_target_ext_addr, ":", + rtext->rt_nhops, prep->prep_hopcount, + rtext->rt_metric, metric); + + rtext->rt_flags = IEEE80211_MESHRT_FLAGS_PROXY | + IEEE80211_MESHRT_FLAGS_VALID; + IEEE80211_ADDR_COPY(rtext->rt_dest, + prep->prep_target_ext_addr); + IEEE80211_ADDR_COPY(rtext->rt_mesh_gate, + prep->prep_targetaddr); + IEEE80211_ADDR_COPY(rtext->rt_nexthop, wh->i_addr2); + rtext->rt_metric = metric; + rtext->rt_lifetime = prep->prep_lifetime; + rtext->rt_nhops = prep->prep_hopcount + 1; + rtext->rt_ext_seq = prep->prep_origseq; /* proxy seq */ + /* proxy entries have no HWMP priv data, nullify them to be sure? */ } /* * Check for frames queued awaiting path discovery. @@ -1320,9 +1376,11 @@ hwmp_recv_prep(struct ieee80211vap *vap, * stuck back on the stageq because there won't be * a path. */ + addr = prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE ? + prep->prep_target_ext_addr : prep->prep_targetaddr; m = ieee80211_ageq_remove(&ic->ic_stageq, (struct ieee80211_node *)(uintptr_t) - ieee80211_mac_hash(ic, rt->rt_dest)); + ieee80211_mac_hash(ic, addr)); /* either dest or ext_dest */ for (; m != NULL; m = next) { next = m->m_nextpkt; m->m_nextpkt = NULL; Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:56:26 2012 (r234878) @@ -284,12 +284,14 @@ ieee80211_mesh_proxy_check(struct ieee80 } else { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest, "%s", "add proxy entry"); + IEEE80211_ADDR_COPY(rt->rt_mesh_gate, vap->iv_myaddr); IEEE80211_ADDR_COPY(rt->rt_nexthop, vap->iv_myaddr); rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID | IEEE80211_MESHRT_FLAGS_PROXY; } - /* XXX assert PROXY? */ } else if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) { + KASSERT(rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY, + ("no proxy flag for poxy entry")); struct ieee80211com *ic = vap->iv_ic; /* * Fix existing entry created by received frames from @@ -910,9 +912,14 @@ mesh_forward(struct ieee80211vap *vap, s struct ieee80211_node *ni; int err; - if (mc->mc_ttl == 0) { + /* + * mesh ttl of 1 means we are the last one receving it, + * according to amendment we decrement and then check if + * 0, if so we dont forward. + */ + if (mc->mc_ttl < 1) { IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, - "%s", "frame not fwd'd, ttl 0"); + "%s", "frame not fwd'd, ttl 1"); vap->iv_stats.is_mesh_fwd_ttl++; return; } @@ -952,6 +959,12 @@ mesh_forward(struct ieee80211vap *vap, s } else { ni = mesh_find_txnode(vap, whcopy->i_addr3); if (ni == NULL) { + /* + * [Optional] any of the following three actions: + * o silently discard + * o trigger a path discovery + * o inform TA that meshDA is unreachable. + */ IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, no path"); vap->iv_stats.is_mesh_fwd_nopath++; @@ -980,9 +993,10 @@ mesh_forward(struct ieee80211vap *vap, s static struct mbuf * mesh_decap(struct ieee80211vap *vap, struct mbuf *m, int hdrlen, int meshdrlen) { -#define WHDIR(wh) ((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) +#define WHDIR(wh) ((wh)->i_fc[1] & IEEE80211_FC1_DIR_MASK) +#define MC01(mc) ((const struct ieee80211_meshcntl_ae01 *)mc) uint8_t b[sizeof(struct ieee80211_qosframe_addr4) + - sizeof(struct ieee80211_meshcntl_ae11)]; + sizeof(struct ieee80211_meshcntl_ae10)]; const struct ieee80211_qosframe_addr4 *wh; const struct ieee80211_meshcntl_ae10 *mc; struct ether_header *eh; @@ -1016,13 +1030,14 @@ mesh_decap(struct ieee80211vap *vap, str m_adj(m, hdrlen - sizeof(*eh)); } eh = mtod(m, struct ether_header *); - ae = mc->mc_flags & 3; + ae = mc->mc_flags & IEEE80211_MESH_AE_MASK; if (WHDIR(wh) == IEEE80211_FC1_DIR_FROMDS) { IEEE80211_ADDR_COPY(eh->ether_dhost, wh->i_addr1); - if (ae == 0) { + if (ae == IEEE80211_MESH_AE_00) { IEEE80211_ADDR_COPY(eh->ether_shost, wh->i_addr3); - } else if (ae == 1) { - IEEE80211_ADDR_COPY(eh->ether_shost, mc->mc_addr4); + } else if (ae == IEEE80211_MESH_AE_01) { + IEEE80211_ADDR_COPY(eh->ether_shost, + MC01(mc)->mc_addr4); } else { IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, (const struct ieee80211_frame *)wh, NULL, @@ -1032,12 +1047,12 @@ mesh_decap(struct ieee80211vap *vap, str return NULL; } } else { - if (ae == 0) { + if (ae == IEEE80211_MESH_AE_00) { IEEE80211_ADDR_COPY(eh->ether_dhost, wh->i_addr3); IEEE80211_ADDR_COPY(eh->ether_shost, wh->i_addr4); - } else if (ae == 2) { - IEEE80211_ADDR_COPY(eh->ether_dhost, mc->mc_addr4); - IEEE80211_ADDR_COPY(eh->ether_shost, mc->mc_addr5); + } else if (ae == IEEE80211_MESH_AE_10) { + IEEE80211_ADDR_COPY(eh->ether_dhost, mc->mc_addr5); + IEEE80211_ADDR_COPY(eh->ether_shost, mc->mc_addr6); } else { IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, (const struct ieee80211_frame *)wh, NULL, @@ -1059,7 +1074,8 @@ mesh_decap(struct ieee80211vap *vap, str eh->ether_type = htons(m->m_pkthdr.len - sizeof(*eh)); } return m; -#undef WDIR +#undef WDIR +#undef MC01 } /* @@ -1075,12 +1091,13 @@ mesh_isucastforme(struct ieee80211vap *v KASSERT((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS, ("bad dir 0x%x:0x%x", wh->i_fc[0], wh->i_fc[1])); - KASSERT(ae == 0 || ae == 2, ("bad AE %d", ae)); - if (ae == 2) { /* ucast w/ proxy */ + KASSERT(ae == IEEE80211_MESH_AE_00 || ae == IEEE80211_MESH_AE_10, + ("bad AE %d", ae)); + if (ae == IEEE80211_MESH_AE_10) { /* ucast w/ proxy */ const struct ieee80211_meshcntl_ae10 *mc10 = (const struct ieee80211_meshcntl_ae10 *) mc; struct ieee80211_mesh_route *rt = - ieee80211_mesh_rt_find(vap, mc10->mc_addr4); + ieee80211_mesh_rt_find(vap, mc10->mc_addr5); /* check for proxy route to ourself */ return (rt != NULL && (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY)); @@ -1088,19 +1105,139 @@ mesh_isucastforme(struct ieee80211vap *v return IEEE80211_ADDR_EQ(wh->i_addr3, vap->iv_myaddr); } +/* + * Verifies transmitter, updates lifetime, precursor list and forwards data. + * > 0 means we have forwarded data and no need to process locally + * == 0 means we want to process locally (and we may have forwarded data + * < 0 means there was an error and data should be discarded + */ +static int +mesh_recv_indiv_data_to_fwrd(struct ieee80211vap *vap, struct mbuf *m, + struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) +{ + + /* + * TODO: + * o verify addr2 is a legitimate transmitter + * o set lifetime of addr3 to initial value + * o set lifetime of addr4 to initial value + * o lifetime of precursor of addr3 (addr2) is max(init, curr) + * o lifetime of precursor of addr4 (nexthop) is max(init, curr) + */ + + mesh_forward(vap, m, mc); + return (1); /* dont process locally */ +} + +/* + * Verifies transmitter, updates lifetime, precursor list and process data + * locally, if data is is proxy with AE = 10 it could mean data should go + * on another mesh path or data should be forwarded to the DS. + * + * > 0 means we have forwarded data and no need to process locally + * == 0 means we want to process locally (and we may have forwarded data + * < 0 means there was an error and data should be discarded + */ +static int +mesh_recv_indiv_data_to_me(struct ieee80211vap *vap, struct mbuf *m, + struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) +{ + struct ieee80211_qosframe_addr4 *qwh; + const struct ieee80211_meshcntl_ae10 *mc10; + struct ieee80211_mesh_route *rt; + int ae; + + qwh = (struct ieee80211_qosframe_addr4 *)wh; + mc10 = (const struct ieee80211_meshcntl_ae10 *)mc; + + /* + * TODO: + * o verify addr2 is a legitimate transmitter + * o set lifetime of addr4 to initial value + * o lifetime of precursor entry is max(init, curr) + */ + + ae = mc10->mc_flags & IEEE80211_MESH_AE_MASK; + KASSERT(ae == IEEE80211_MESH_AE_00 || + ae == IEEE80211_MESH_AE_10, ("bad AE %d", ae)); + if (ae == IEEE80211_MESH_AE_10) { + if (IEEE80211_ADDR_EQ(mc10->mc_addr5, qwh->i_addr3)) { + return (0); /* process locally */ + } + + rt = ieee80211_mesh_rt_find(vap, mc10->mc_addr5); + if (rt != NULL && + (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) && + (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) == 0) { + /* + * Forward on another mesh-path, according to + * amendment as specified in 9.32.4.1 + */ + IEEE80211_ADDR_COPY(qwh->i_addr3, mc10->mc_addr5); + mesh_forward(vap, m, + (const struct ieee80211_meshcntl *)mc10); + return (1); /* dont process locally */ + } + /* + * All other cases: forward of MSDUs from the MBSS to DS indiv. + * addressed according to 13.11.3.2. + */ + } + return (0); /* process locally */ +} + +/* + * Try to forward the group addressed data on to other mesh STAs, and + * also to the DS. + * + * > 0 means we have forwarded data and no need to process locally + * == 0 means we want to process locally (and we may have forwarded data + * < 0 means there was an error and data should be discarded + */ +static int +mesh_recv_group_data(struct ieee80211vap *vap, struct mbuf *m, + struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) +{ +#define MC01(mc) ((const struct ieee80211_meshcntl_ae01 *)mc) + struct ieee80211_mesh_state *ms = vap->iv_mesh; + + mesh_forward(vap, m, mc); + + if(mc->mc_ttl > 0) { + if (mc->mc_flags & IEEE80211_MESH_AE_01) { + /* + * Forward of MSDUs from the MBSS to DS group addressed + * (according to 13.11.3.2) + * This happens by delivering the packet, and a bridge + * will sent it on another port member. + */ + if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL && + ms->ms_flags & IEEE80211_MESHFLAGS_FWD) + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, + MC01(mc)->mc_addr4, "%s", + "forward from MBSS to the DS"); + } + } + return (0); /* process locally */ +#undef MC01 +} + static int mesh_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf) { #define HAS_SEQ(type) ((type & 0x4) == 0) +#define MC01(mc) ((const struct ieee80211_meshcntl_ae01 *)mc) +#define MC10(mc) ((const struct ieee80211_meshcntl_ae10 *)mc) struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; struct ifnet *ifp = vap->iv_ifp; struct ieee80211_frame *wh; const struct ieee80211_meshcntl *mc; - int hdrspace, meshdrlen, need_tap; - uint8_t dir, type, subtype; + int hdrspace, meshdrlen, need_tap, error; + uint8_t dir, type, subtype, ae; uint32_t seq; - uint8_t *addr, qos[2]; + const uint8_t *addr; + uint8_t qos[2]; ieee80211_seq rxseq; KASSERT(ni != NULL, ("null node")); @@ -1189,7 +1326,7 @@ mesh_input(struct ieee80211_node *ni, st ni->ni_mlstate); vap->iv_stats.is_mesh_nolink++; goto out; - } + } if (dir != IEEE80211_FC1_DIR_FROMDS && dir != IEEE80211_FC1_DIR_DSTODS) { IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, @@ -1271,12 +1408,28 @@ mesh_input(struct ieee80211_node *ni, st */ mc = (const struct ieee80211_meshcntl *) (mtod(m, const uint8_t *) + hdrspace); + ae = mc->mc_flags & IEEE80211_MESH_AE_MASK; meshdrlen = sizeof(struct ieee80211_meshcntl) + - (mc->mc_flags & 3) * IEEE80211_ADDR_LEN; + ae * IEEE80211_ADDR_LEN; hdrspace += meshdrlen; + + /* pull complete hdrspace = ieee80211_hdrspace + meshcontrol */ + if ((meshdrlen > sizeof(struct ieee80211_meshcntl)) && + (m->m_len < hdrspace) && + ((m = m_pullup(m, hdrspace)) == NULL)) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + ni->ni_macaddr, NULL, + "data too short: expecting %u", hdrspace); + vap->iv_stats.is_rx_tooshort++; + goto out; /* XXX */ + } + /* XXX: are we sure there is no reallocating after m_pullup? */ + seq = LE_READ_4(mc->mc_seq); if (IEEE80211_IS_MULTICAST(wh->i_addr1)) addr = wh->i_addr3; + else if (ae == IEEE80211_MESH_AE_01) + addr = MC01(mc)->mc_addr4; else addr = ((struct ieee80211_qosframe_addr4 *)wh)->i_addr4; if (IEEE80211_ADDR_EQ(vap->iv_myaddr, addr)) { @@ -1290,17 +1443,22 @@ mesh_input(struct ieee80211_node *ni, st goto out; } - /* - * Potentially forward packet. See table s36 (p140) - * for the rules. XXX tap fwd'd packets not for us? - */ - if (dir == IEEE80211_FC1_DIR_FROMDS || - !mesh_isucastforme(vap, wh, mc)) { - mesh_forward(vap, m, mc); - if (dir == IEEE80211_FC1_DIR_DSTODS) - goto out; - /* NB: fall thru to deliver mcast frames locally */ - } + /* This code "routes" the frame to the right control path */ + if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr3)) + error = + mesh_recv_indiv_data_to_me(vap, m, wh, mc); + else if (IEEE80211_IS_MULTICAST(wh->i_addr3)) + error = mesh_recv_group_data(vap, m, wh, mc); + else + error = mesh_recv_indiv_data_to_fwrd(vap, m, + wh, mc); + } else + error = mesh_recv_group_data(vap, m, wh, mc); + if (error < 0) + goto err; + else if (error > 0) + goto out; if (ieee80211_radiotap_active_vap(vap)) ieee80211_radiotap_rx(vap, m); @@ -1382,6 +1540,9 @@ out: m_freem(m); } return type; +#undef HAS_SEQ +#undef MC01 +#undef MC10 } static void @@ -2616,7 +2777,7 @@ ieee80211_add_meshpeer(uint8_t *frm, uin */ #define IEEE80211_MESH_MAXOVERHEAD \ (sizeof(struct ieee80211_qosframe_addr4) \ - + sizeof(struct ieee80211_meshcntl_ae11) \ + + sizeof(struct ieee80211_meshcntl_ae10) \ + sizeof(struct llc) \ + IEEE80211_ADDR_LEN \ + IEEE80211_WEP_IVLEN \ Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 15:56:26 2012 (r234878) @@ -390,19 +390,18 @@ struct ieee80211_meshcntl_ae10 { uint8_t mc_flags; /* Address Extension 10 */ uint8_t mc_ttl; /* TTL */ uint8_t mc_seq[4]; /* Sequence No. */ - uint8_t mc_addr4[IEEE80211_ADDR_LEN]; - uint8_t mc_addr5[IEEE80211_ADDR_LEN]; -} __packed; - -struct ieee80211_meshcntl_ae11 { - uint8_t mc_flags; /* Address Extension 11 */ - uint8_t mc_ttl; /* TTL */ - uint8_t mc_seq[4]; /* Sequence No. */ - uint8_t mc_addr4[IEEE80211_ADDR_LEN]; uint8_t mc_addr5[IEEE80211_ADDR_LEN]; uint8_t mc_addr6[IEEE80211_ADDR_LEN]; } __packed; +#define IEEE80211_MESH_AE_MASK 0x03 +enum { + IEEE80211_MESH_AE_00 = 0, /* MC has no AE subfield */ + IEEE80211_MESH_AE_01 = 1, /* MC contain addr4 */ + IEEE80211_MESH_AE_10 = 2, /* MC contain addr5 & addr6 */ + IEEE80211_MESH_AE_11 = 3, /* RESERVED */ +}; + #ifdef _KERNEL MALLOC_DECLARE(M_80211_MESH_PREQ); MALLOC_DECLARE(M_80211_MESH_PREP); @@ -423,6 +422,7 @@ struct ieee80211_mesh_route { struct mtx rt_lock; /* fine grained route lock */ int rt_updtime; /* last update time */ uint8_t rt_dest[IEEE80211_ADDR_LEN]; + uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */ uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; uint32_t rt_metric; /* path metric */ uint16_t rt_nhops; /* number of hops */ @@ -431,6 +431,7 @@ struct ieee80211_mesh_route { #define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ + uint32_t rt_ext_seq; /* proxy seq number */ void *rt_priv; /* private data */ }; #define IEEE80211_MESH_ROUTE_PRIV(rt, cast) ((cast *)rt->rt_priv) Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Tue May 1 15:47:30 2012 (r234877) +++ head/sys/net80211/ieee80211_output.c Tue May 1 15:56:26 2012 (r234878) @@ -254,7 +254,7 @@ ieee80211_start(struct ifnet *ifp) if (!ieee80211_mesh_isproxyena(vap)) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_OUTPUT | - IEEE80211_MSG_MESH, + IEEE80211_MSG_MESH, eh->ether_dhost, NULL, "%s", "proxy not enabled"); vap->iv_stats.is_mesh_notproxy++; @@ -363,7 +363,6 @@ ieee80211_start(struct ifnet *ifp) continue; } } - error = parent->if_transmit(parent, m); if (error != 0) { /* NB: IFQ_HANDOFF reclaims mbuf */ @@ -556,7 +555,6 @@ ieee80211_send_setup( break; case IEEE80211_M_MBSS: #ifdef IEEE80211_SUPPORT_MESH - /* XXX add support for proxied addresses */ if (IEEE80211_IS_MULTICAST(da)) { wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS; /* XXX next hop */ @@ -1016,10 +1014,13 @@ ieee80211_encap(struct ieee80211vap *vap struct mbuf *m) { #define WH4(wh) ((struct ieee80211_frame_addr4 *)(wh)) +#define MC01(mc) ((struct ieee80211_meshcntl_ae01 *)mc) struct ieee80211com *ic = ni->ni_ic; #ifdef IEEE80211_SUPPORT_MESH struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_meshcntl_ae10 *mc; + struct ieee80211_mesh_route *rt = NULL; + int dir = -1; #endif struct ether_header eh; struct ieee80211_frame *wh; @@ -1100,21 +1101,40 @@ ieee80211_encap(struct ieee80211vap *vap * w/ 4-address format and address extension mode 10 */ is4addr = 0; /* NB: don't use, disable */ - if (!IEEE80211_IS_MULTICAST(eh.ether_dhost)) - hdrsize += IEEE80211_ADDR_LEN; /* unicast are 4-addr */ - meshhdrsize = sizeof(struct ieee80211_meshcntl); - /* XXX defines for AE modes */ - if (IEEE80211_ADDR_EQ(eh.ether_shost, vap->iv_myaddr)) { - if (!IEEE80211_IS_MULTICAST(eh.ether_dhost)) - meshae = 0; - else - meshae = 4; /* NB: pseudo */ - } else if (IEEE80211_IS_MULTICAST(eh.ether_dhost)) { - meshae = 1; - meshhdrsize += 1*IEEE80211_ADDR_LEN; + if (!IEEE80211_IS_MULTICAST(eh.ether_dhost)) { + rt = ieee80211_mesh_rt_find(vap, eh.ether_dhost); + KASSERT(rt != NULL, ("route is NULL")); + dir = IEEE80211_FC1_DIR_DSTODS; + hdrsize += IEEE80211_ADDR_LEN; + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { + if (IEEE80211_ADDR_EQ(rt->rt_mesh_gate, + vap->iv_myaddr)) { + IEEE80211_NOTE_MAC(vap, + IEEE80211_MSG_MESH, + eh.ether_dhost, + "%s", "trying to send to ourself"); + goto bad; + } + meshae = IEEE80211_MESH_AE_10; + meshhdrsize = + sizeof(struct ieee80211_meshcntl_ae10); + } else { + meshae = IEEE80211_MESH_AE_00; + meshhdrsize = + sizeof(struct ieee80211_meshcntl); + } } else { - meshae = 2; - meshhdrsize += 2*IEEE80211_ADDR_LEN; + dir = IEEE80211_FC1_DIR_FROMDS; + if (!IEEE80211_ADDR_EQ(eh.ether_shost, vap->iv_myaddr)) { + /* proxy group */ + meshae = IEEE80211_MESH_AE_01; + meshhdrsize = + sizeof(struct ieee80211_meshcntl_ae01); + } else { + /* group */ + meshae = IEEE80211_MESH_AE_00; + meshhdrsize = sizeof(struct ieee80211_meshcntl); + } } } else { #endif @@ -1215,44 +1235,52 @@ ieee80211_encap(struct ieee80211vap *vap /* NB: offset by hdrspace to deal with DATAPAD */ mc = (struct ieee80211_meshcntl_ae10 *) (mtod(m, uint8_t *) + hdrspace); + wh->i_fc[1] = dir; switch (meshae) { - case 0: /* ucast, no proxy */ - wh->i_fc[1] = IEEE80211_FC1_DIR_DSTODS; - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr); - IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); - IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost); - IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, eh.ether_shost); + case IEEE80211_MESH_AE_00: /* no proxy */ mc->mc_flags = 0; - qos = ((struct ieee80211_qosframe_addr4 *) wh)->i_qos; - break; - case 4: /* mcast, no proxy */ - wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS; - IEEE80211_ADDR_COPY(wh->i_addr1, eh.ether_dhost); - IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); - IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_shost); - mc->mc_flags = 0; /* NB: AE is really 0 */ - qos = ((struct ieee80211_qosframe *) wh)->i_qos; + if (dir == IEEE80211_FC1_DIR_DSTODS) { /* ucast */ + IEEE80211_ADDR_COPY(wh->i_addr1, + ni->ni_macaddr); + IEEE80211_ADDR_COPY(wh->i_addr2, + vap->iv_myaddr); + IEEE80211_ADDR_COPY(wh->i_addr3, + eh.ether_dhost); + IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, + eh.ether_shost); + qos =((struct ieee80211_qosframe_addr4 *) + wh)->i_qos; + } else if (dir == IEEE80211_FC1_DIR_FROMDS) { + /* mcast */ + IEEE80211_ADDR_COPY(wh->i_addr1, + eh.ether_dhost); + IEEE80211_ADDR_COPY(wh->i_addr2, + vap->iv_myaddr); + IEEE80211_ADDR_COPY(wh->i_addr3, + eh.ether_shost); + qos = ((struct ieee80211_qosframe *) + wh)->i_qos; + } break; - case 1: /* mcast, proxy */ + case IEEE80211_MESH_AE_01: /* mcast, proxy */ wh->i_fc[1] = IEEE80211_FC1_DIR_FROMDS; IEEE80211_ADDR_COPY(wh->i_addr1, eh.ether_dhost); IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); IEEE80211_ADDR_COPY(wh->i_addr3, vap->iv_myaddr); mc->mc_flags = 1; - IEEE80211_ADDR_COPY(mc->mc_addr4, eh.ether_shost); + IEEE80211_ADDR_COPY(MC01(mc)->mc_addr4, + eh.ether_shost); qos = ((struct ieee80211_qosframe *) wh)->i_qos; break; - case 2: /* ucast, proxy */ - wh->i_fc[1] = IEEE80211_FC1_DIR_DSTODS; - IEEE80211_ADDR_COPY(wh->i_addr1, ni->ni_macaddr); + case IEEE80211_MESH_AE_10: /* ucast, proxy */ + KASSERT(rt != NULL, ("route is NULL")); + IEEE80211_ADDR_COPY(wh->i_addr1, rt->rt_nexthop); IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr); - /* XXX not right, need MeshDA */ - IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost); - /* XXX assume are MeshSA */ + IEEE80211_ADDR_COPY(wh->i_addr3, rt->rt_mesh_gate); IEEE80211_ADDR_COPY(WH4(wh)->i_addr4, vap->iv_myaddr); - mc->mc_flags = 2; - IEEE80211_ADDR_COPY(mc->mc_addr4, eh.ether_dhost); - IEEE80211_ADDR_COPY(mc->mc_addr5, eh.ether_shost); + mc->mc_flags = IEEE80211_MESH_AE_10; + IEEE80211_ADDR_COPY(mc->mc_addr5, eh.ether_dhost); + IEEE80211_ADDR_COPY(mc->mc_addr6, eh.ether_shost); qos = ((struct ieee80211_qosframe_addr4 *) wh)->i_qos; break; default: @@ -1363,6 +1391,7 @@ bad: m_freem(m); return NULL; #undef WH4 +#undef MC01 } /* From owner-svn-src-head@FreeBSD.ORG Tue May 1 15:58:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 461C6106566C; Tue, 1 May 2012 15:58:11 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 316548FC0A; Tue, 1 May 2012 15:58:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41FwBcG033091; Tue, 1 May 2012 15:58:11 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41FwAkY033089; Tue, 1 May 2012 15:58:10 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011558.q41FwAkY033089@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 15:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234879 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 15:58:11 -0000 Author: monthadar Date: Tue May 1 15:58:10 2012 New Revision: 234879 URL: http://svn.freebsd.org/changeset/base/234879 Log: Added route lifetime update for destination and source mesh along a mesh path; * In mesh_recv_indiv_data_to_fwd update route entry for both meshDA and meshSA; * In mesh_recv_indiv_data_to_me update route entry for meshSA; * in ieee80211_mesh_rt_update put code so that a proxy entry that is gated by us (number of hops == 0) is never invalidated; * Fixed so that we always call ieee80211_mesh_rt_update with lifetime in ms; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:56:26 2012 (r234878) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 15:58:10 2012 (r234879) @@ -241,6 +241,13 @@ ieee80211_mesh_rt_update(struct ieee8021 now = ticks; RT_ENTRY_LOCK(rt); + + /* dont clobber a proxy entry gated by us */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY && rt->rt_nhops == 0) { + RT_ENTRY_UNLOCK(rt); + return rt->rt_lifetime; + } + timesince = ticks_to_msecs(now - rt->rt_updtime); rt->rt_updtime = now; if (timesince >= rt->rt_lifetime) { @@ -1115,16 +1122,31 @@ static int mesh_recv_indiv_data_to_fwrd(struct ieee80211vap *vap, struct mbuf *m, struct ieee80211_frame *wh, const struct ieee80211_meshcntl *mc) { + struct ieee80211_qosframe_addr4 *qwh; + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_mesh_route *rt_meshda, *rt_meshsa; + + qwh = (struct ieee80211_qosframe_addr4 *)wh; /* * TODO: * o verify addr2 is a legitimate transmitter - * o set lifetime of addr3 to initial value - * o set lifetime of addr4 to initial value * o lifetime of precursor of addr3 (addr2) is max(init, curr) * o lifetime of precursor of addr4 (nexthop) is max(init, curr) */ + /* set lifetime of addr3 (meshDA) to initial value */ + rt_meshda = ieee80211_mesh_rt_find(vap, qwh->i_addr3); + KASSERT(rt_meshda != NULL, ("no route")); + ieee80211_mesh_rt_update(rt_meshda, ticks_to_msecs( + ms->ms_ppath->mpp_inact)); + + /* set lifetime of addr4 (meshSA) to initial value */ + rt_meshsa = ieee80211_mesh_rt_find(vap, qwh->i_addr4); + KASSERT(rt_meshsa != NULL, ("no route")); + ieee80211_mesh_rt_update(rt_meshsa, ticks_to_msecs( + ms->ms_ppath->mpp_inact)); + mesh_forward(vap, m, mc); return (1); /* dont process locally */ } @@ -1144,6 +1166,7 @@ mesh_recv_indiv_data_to_me(struct ieee80 { struct ieee80211_qosframe_addr4 *qwh; const struct ieee80211_meshcntl_ae10 *mc10; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt; int ae; @@ -1153,10 +1176,15 @@ mesh_recv_indiv_data_to_me(struct ieee80 /* * TODO: * o verify addr2 is a legitimate transmitter - * o set lifetime of addr4 to initial value * o lifetime of precursor entry is max(init, curr) */ + /* set lifetime of addr4 (meshSA) to initial value */ + rt = ieee80211_mesh_rt_find(vap, qwh->i_addr4); + KASSERT(rt != NULL, ("no route")); + ieee80211_mesh_rt_update(rt, ticks_to_msecs(ms->ms_ppath->mpp_inact)); + rt = NULL; + ae = mc10->mc_flags & IEEE80211_MESH_AE_MASK; KASSERT(ae == IEEE80211_MESH_AE_00 || ae == IEEE80211_MESH_AE_10, ("bad AE %d", ae)); @@ -1673,7 +1701,8 @@ mesh_recv_mgmt(struct ieee80211_node *ni rt = ieee80211_mesh_rt_find(vap, wh->i_addr2); if(rt != NULL) { ieee80211_mesh_rt_update(rt, - ms->ms_ppath->mpp_inact); + ticks_to_msecs( + ms->ms_ppath->mpp_inact)); } break; } From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:00:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5DF751065670; Tue, 1 May 2012 16:00:32 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48E018FC08; Tue, 1 May 2012 16:00:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G0WXh033233; Tue, 1 May 2012 16:00:32 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G0Wsi033230; Tue, 1 May 2012 16:00:32 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011600.q41G0Wsi033230@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:00:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234880 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:00:32 -0000 Author: monthadar Date: Tue May 1 16:00:31 2012 New Revision: 234880 URL: http://svn.freebsd.org/changeset/base/234880 Log: * MeshForwarding update mesh_recv_indiv_data_to_fwrd to silently discard unknown meshDA instead of panic, which is allowed per amendment spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_mesh.c Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 15:58:10 2012 (r234879) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:00:31 2012 (r234880) @@ -1137,7 +1137,19 @@ mesh_recv_indiv_data_to_fwrd(struct ieee /* set lifetime of addr3 (meshDA) to initial value */ rt_meshda = ieee80211_mesh_rt_find(vap, qwh->i_addr3); - KASSERT(rt_meshda != NULL, ("no route")); + if (rt_meshda == NULL) { + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, qwh->i_addr2, + "no route to meshDA(%6D)", qwh->i_addr3, ":"); + /* + * [Optional] any of the following three actions: + * o silently discard [X] + * o trigger a path discovery [ ] + * o inform TA that meshDA is unknown. [ ] + */ + /* XXX: stats */ + return (-1); + } + ieee80211_mesh_rt_update(rt_meshda, ticks_to_msecs( ms->ms_ppath->mpp_inact)); From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:02:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3A100106566C; Tue, 1 May 2012 16:02:32 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D9D038FC0A; Tue, 1 May 2012 16:02:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G2VJk033354; Tue, 1 May 2012 16:02:31 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G2Vrk033351; Tue, 1 May 2012 16:02:31 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011602.q41G2Vrk033351@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:02:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234881 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:02:32 -0000 Author: monthadar Date: Tue May 1 16:02:31 2012 New Revision: 234881 URL: http://svn.freebsd.org/changeset/base/234881 Log: PREP update * Added assertion in mesh_rt_update; * Fixed some prep propagation that where multicast, ALL PREPS ARE UNICAST; * Fixed PREP acceptance criteria; * Fixed some PREP debug messages; * HWMP intermediate reply (PREP) should only be sent if we have newer forwarding infomration (FI) about target; * Fixed PREP propagation condition and PREP w/ AE handling; * Ignore PREPs that have unknown originator. * Removed old code inside PREP that was for proactive path building to root mesh; Other errors include: * use seq number of target and not orig mesh STA; * Metric is what we have stored in our FI; * Error in amendment, Hop count is not 0 but equals FI hopcount for target; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:00:31 2012 (r234880) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:02:31 2012 (r234881) @@ -887,7 +887,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, return; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "received PREQ, source %6D", preq->preq_origaddr, ":"); + "received PREQ, orig %6D, targ(0) %6D", preq->preq_origaddr, ":", + PREQ_TADDR(0), ":"); /* * Acceptance criteria: if the PREQ is not for us or not broadcast @@ -1010,9 +1011,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, * root STA if requested. */ if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr) && - (PREQ_TFLAGS(0) & - ((IEEE80211_MESHPREQ_TFLAGS_TO|IEEE80211_MESHPREQ_TFLAGS_RF) == - (IEEE80211_MESHPREQ_TFLAGS_TO|IEEE80211_MESHPREQ_TFLAGS_RF)))) { + (PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { uint8_t rootmac[IEEE80211_ADDR_LEN]; IEEE80211_ADDR_COPY(rootmac, preq->preq_origaddr); @@ -1096,26 +1095,26 @@ hwmp_recv_preq(struct ieee80211vap *vap, * Check if we can send an intermediate Path Reply, * i.e., Target Only bit is not set. */ - if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { + if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO) && + HWMP_SEQ_GEQ(hrtarg->hr_seq, PREQ_TSEQ(0))) { struct ieee80211_meshprep_ie prep; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "intermediate reply for PREQ from %6D", preq->preq_origaddr, ":"); prep.prep_flags = 0; - prep.prep_hopcount = rt->rt_nhops + 1; + prep.prep_hopcount = rttarg->rt_nhops; prep.prep_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(&prep.prep_targetaddr, PREQ_TADDR(0)); - prep.prep_targetseq = hrorig->hr_seq; + prep.prep_targetseq = hrtarg->hr_seq; prep.prep_lifetime = preq->preq_lifetime; - prep.prep_metric = rt->rt_metric + - ms->ms_pmetric->mpm_metric(ni); + prep.prep_metric =rttarg->rt_metric; IEEE80211_ADDR_COPY(&prep.prep_origaddr, preq->preq_origaddr); prep.prep_origseq = hrorig->hr_seq; hwmp_send_prep(ni, vap->iv_myaddr, - broadcastaddr, &prep); + rtorig->rt_nexthop, &prep); } /* * We have no information about this path, @@ -1191,6 +1190,9 @@ static void hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshprep_ie *prep) { +#define IS_PROXY(rt) (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) +#define PROXIED_BY_US(rt) \ + (IEEE80211_ADDR_EQ(vap->iv_myaddr, rt->rt_mesh_gate)) struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_mesh_route *rt = NULL; @@ -1203,63 +1205,31 @@ hwmp_recv_prep(struct ieee80211vap *vap, uint32_t metric = 0; const uint8_t *addr; - /* - * Acceptance criteria: If the corresponding PREP was not generated - * by us or generated by an external mac that is proxied by us - * and forwarding is disabled, discard this PREP. - */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) return; - if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && - !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) - return; + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP, orig %6D, targ %6D", prep->prep_origaddr, ":", + prep->prep_targetaddr, ":"); + + /* + * Acceptance criteria: (If the corresponding PREP was not generated + * by us OR not generated by an external mac that is not proxied by us) + * AND forwarding is disabled, discard this PREP. + */ rtorig = ieee80211_mesh_rt_find(vap, prep->prep_origaddr); - if (rtorig != NULL && - !(rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY)) { + if ((!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) || + (rtorig != NULL && IS_PROXY(rtorig) && !PROXIED_BY_US(rtorig))) && + !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)){ IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "received PREP(%u) for an orig(%6D) not proxied by us", - prep->prep_origseq, prep->prep_origaddr, ":"); + "discard PREP, orig(%6D) not proxied or generated by us", + prep->prep_origaddr, ":"); return; } /* PREP ACCEPTED */ - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "received PREP from %6D", prep->prep_targetaddr, ":"); - -#if 0 - rt = ieee80211_mesh_rt_find(vap, prep->prep_targetaddr); - if (rt == NULL) { - /* - * If we have no entry this could be a reply to a root PREQ. - * XXX: not true anymore cause we dont create entry for target - * when propagating PREQs like the old code did. - */ - if (hs->hs_rootmode != IEEE80211_HWMP_ROOTMODE_DISABLED) { - rt = ieee80211_mesh_rt_add(vap, prep->prep_targetaddr); - if (rt == NULL) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, - ni, "unable to add PREP path to %6D", - prep->prep_targetaddr, ":"); - vap->iv_stats.is_mesh_rtaddfailed++; - return; - } - IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); - rt->rt_nhops = prep->prep_hopcount; - ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_metric = prep->prep_metric; - rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "add root path to %6D nhops %d metric %lu (PREP)", - prep->prep_targetaddr, ":", - rt->rt_nhops, rt->rt_metric); - return; - } - return; - } -#endif - /* * If accepted shall create or update the active forwarding information * it maintains for the target mesh STA of the PREP (according to the @@ -1278,6 +1248,8 @@ hwmp_recv_prep(struct ieee80211vap *vap, vap->iv_stats.is_mesh_rtaddfailed++; return; } + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "adding target %6D", prep->prep_targetaddr, ":"); } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); /* update path metric */ @@ -1315,11 +1287,25 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ /* - * If it's NOT for us, propagate the PREP. + * If it's NOT for us, propagate the PREP */ if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && - prep->prep_ttl > 1 && prep->prep_hopcount < hs->hs_maxhops) { + prep->prep_ttl > 1 && + prep->prep_hopcount < hs->hs_maxhops) { struct ieee80211_meshprep_ie pprep; /* propagated PREP */ + /* + * NB: We should already have setup the path to orig + * mesh STA when we propagated PREQ to target mesh STA, + * no PREP is generated without a corresponding PREQ. + * XXX: for now just ignore. + */ + if (rtorig == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP for an unknown orig(%6D)", + prep->prep_origaddr, ":"); + return; + } + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "propagate PREP from %6D", prep->prep_targetaddr, ":"); @@ -1328,13 +1314,17 @@ hwmp_recv_prep(struct ieee80211vap *vap, pprep.prep_hopcount += 1; pprep.prep_ttl -= 1; pprep.prep_metric += ms->ms_pmetric->mpm_metric(ni); - hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr, &pprep); + hwmp_send_prep(ni, vap->iv_myaddr, rtorig->rt_nexthop, &pprep); - /* may store target external address if recevied PREP w/ AE */ /* precursor list for the Target Mesh STA Address is updated */ } - /* check if we received a PREP for a proxy address */ - else if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { + + /* + * Check if we received a PREP w/ AE and store target external address. + * We may store target external address if recevied PREP w/ AE + * and we are not final destination + */ + if (prep->prep_flags & IEEE80211_MESHPREP_FLAGS_AE) { rtext = ieee80211_mesh_rt_find(vap, prep->prep_target_ext_addr); if (rtext == NULL) { @@ -1366,8 +1356,11 @@ hwmp_recv_prep(struct ieee80211vap *vap, rtext->rt_metric = metric; rtext->rt_lifetime = prep->prep_lifetime; rtext->rt_nhops = prep->prep_hopcount + 1; - rtext->rt_ext_seq = prep->prep_origseq; /* proxy seq */ - /* proxy entries have no HWMP priv data, nullify them to be sure? */ + rtext->rt_ext_seq = prep->prep_origseq; /* new proxy seq */ + /* + * XXX: proxy entries have no HWMP priv data, + * nullify them to be sure? + */ } /* * Check for frames queued awaiting path discovery. @@ -1388,6 +1381,8 @@ hwmp_recv_prep(struct ieee80211vap *vap, "flush queued frame %p len %d", m, m->m_pkthdr.len); ifp->if_transmit(ifp, m); } +#undef IS_PROXY +#undef PROXIED_BY_US } static int Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:00:31 2012 (r234880) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:02:31 2012 (r234881) @@ -239,6 +239,8 @@ ieee80211_mesh_rt_update(struct ieee8021 int timesince, now; uint32_t lifetime = 0; + KASSERT(rt != NULL, ("route is NULL")); + now = ticks; RT_ENTRY_LOCK(rt); From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:03:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 08FD3106564A; Tue, 1 May 2012 16:03:28 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E817E8FC22; Tue, 1 May 2012 16:03:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G3RrT033424; Tue, 1 May 2012 16:03:27 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G3R9b033422; Tue, 1 May 2012 16:03:27 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011603.q41G3R9b033422@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:03:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234882 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:03:28 -0000 Author: monthadar Date: Tue May 1 16:03:27 2012 New Revision: 234882 URL: http://svn.freebsd.org/changeset/base/234882 Log: Change how we enforce PREQ minimum interval. * Moved hs_lastpreq to be hr_lastpreq cause this rate check should be per target mesh STA according to amendment (NB: not applicable for PERR); * Modified hwmp_send_preq to use two extra arguments for last sent PREQ and minimum PREQ interval; * hwmp_send_preq is called with last two arguments equal to NULL when sending Proactive PREQs cause the call back task enforces the rate check; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:02:31 2012 (r234881) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:03:27 2012 (r234882) @@ -89,7 +89,8 @@ static void hwmp_recv_preq(struct ieee80 static int hwmp_send_preq(struct ieee80211_node *, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], - struct ieee80211_meshpreq_ie *); + struct ieee80211_meshpreq_ie *, + struct timeval *, struct timeval *); static void hwmp_recv_prep(struct ieee80211vap *, struct ieee80211_node *, const struct ieee80211_frame *, const struct ieee80211_meshprep_ie *); @@ -152,14 +153,14 @@ struct ieee80211_hwmp_route { ieee80211_hwmp_seq hr_seq; /* last HWMP seq seen from dst*/ ieee80211_hwmp_seq hr_preqid; /* last PREQ ID seen from dst */ ieee80211_hwmp_seq hr_origseq; /* seq. no. on our latest PREQ*/ + struct timeval hr_lastpreq; /* last time we sent a PREQ */ int hr_preqretries; }; struct ieee80211_hwmp_state { ieee80211_hwmp_seq hs_seq; /* next seq to be used */ ieee80211_hwmp_seq hs_preqid; /* next PREQ ID to be used */ - struct timeval hs_lastpreq; /* last time we sent a PREQ */ - struct timeval hs_lastperr; /* last time we sent a PERR */ int hs_rootmode; /* proactive HWMP */ + struct timeval hs_lastperr; /* last time we sent a PERR */ struct callout hs_roottimer; uint8_t hs_maxhops; /* max hop count */ }; @@ -824,7 +825,8 @@ hwmp_rootmode_cb(void *arg) IEEE80211_MESHPREQ_TFLAGS_RF; PREQ_TSEQ(0) = 0; vap->iv_stats.is_hwmp_rootreqs++; - hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq); + hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, + NULL, NULL); /* NB: we enforce rate check ourself */ hwmp_rootmode_setup(vap); } #undef PREQ_TFLAGS @@ -1051,7 +1053,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, hwmp_discover(vap, rootmac, NULL); return; } - rt = ieee80211_mesh_rt_find(vap, PREQ_TADDR(0)); /* * Forwarding and Intermediate reply for PREQs with 1 target. @@ -1063,8 +1064,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* * We have a valid route to this node. */ - if (rt != NULL && - (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { + if (rttarg != NULL && + (rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { if (preq->preq_ttl > 1 && preq->preq_hopcount < hs->hs_maxhops) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1072,7 +1073,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, preq->preq_origaddr, ":"); /* * Propagate the original PREQ. - * PREQ is unicast now to rt->rt_nexthop + * PREQ is unicast now to rttarg->rt_nexthop */ ppreq.preq_flags &= ~IEEE80211_MESHPREQ_FLAGS_AM; @@ -1089,7 +1090,9 @@ hwmp_recv_preq(struct ieee80211vap *vap, ppreq.preq_targets[0].target_flags &= ~IEEE80211_MESHPREQ_TFLAGS_RF; hwmp_send_preq(ni, vap->iv_myaddr, - rt->rt_nexthop, &ppreq); + rttarg->rt_nexthop, &ppreq, + &hrtarg->hr_lastpreq, + &ieee80211_hwmp_preqminint); } /* * Check if we can send an intermediate Path Reply, @@ -1122,9 +1125,10 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ } else if (preq->preq_ttl > 1 && preq->preq_hopcount < hs->hs_maxhops) { - if (rt == NULL) { - rt = ieee80211_mesh_rt_add(vap, PREQ_TADDR(0)); - if (rt == NULL) { + if (rttarg == NULL) { + rttarg = + ieee80211_mesh_rt_add(vap, PREQ_TADDR(0)); + if (rttarg == NULL) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add PREQ path to %6D", @@ -1133,12 +1137,12 @@ hwmp_recv_preq(struct ieee80211vap *vap, return; } } - rt->rt_metric = preq->preq_metric; - ieee80211_mesh_rt_update(rt, preq->preq_lifetime); - hrorig = IEEE80211_MESH_ROUTE_PRIV(rt, + rttarg->rt_metric = preq->preq_metric; + ieee80211_mesh_rt_update(rttarg, preq->preq_lifetime); + hrtarg = IEEE80211_MESH_ROUTE_PRIV(rttarg, struct ieee80211_hwmp_route); - hrorig->hr_seq = preq->preq_origseq; - hrorig->hr_preqid = preq->preq_id; + hrtarg->hr_seq = PREQ_TSEQ(0); + hrtarg->hr_preqid = preq->preq_id; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "forward PREQ from %6D", @@ -1147,7 +1151,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, ppreq.preq_ttl -= 1; ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, - &ppreq); + &ppreq, &hrtarg->hr_lastpreq, + &ieee80211_hwmp_preqminint); } } } @@ -1159,16 +1164,19 @@ static int hwmp_send_preq(struct ieee80211_node *ni, const uint8_t sa[IEEE80211_ADDR_LEN], const uint8_t da[IEEE80211_ADDR_LEN], - struct ieee80211_meshpreq_ie *preq) + struct ieee80211_meshpreq_ie *preq, + struct timeval *last, struct timeval *minint) { - struct ieee80211_hwmp_state *hs = ni->ni_vap->iv_hwmp; /* * Enforce PREQ interval. + * NB: Proactive ROOT PREQs rate is handled by cb task. */ - if (ratecheck(&hs->hs_lastpreq, &ieee80211_hwmp_preqminint) == 0) - return EALREADY; - getmicrouptime(&hs->hs_lastpreq); + if (last != NULL && minint != NULL) { + if (ratecheck(last, minint) == 0) + return EALREADY; /* XXX: we should postpone */ + getmicrouptime(last); + } /* * mesh preq action frame format @@ -1677,7 +1685,8 @@ hwmp_discover(struct ieee80211vap *vap, PREQ_TSEQ(0) = hr->hr_seq; /* XXX check return value */ hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, - broadcastaddr, &preq); + broadcastaddr, &preq, &hr->hr_lastpreq, + &ieee80211_hwmp_preqminint); } if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) ni = ieee80211_find_txnode(vap, rt->rt_nexthop); From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:05:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97F94106564A; Tue, 1 May 2012 16:05:10 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8376C8FC08; Tue, 1 May 2012 16:05:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G5A0M033519; Tue, 1 May 2012 16:05:10 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G5Aq9033517; Tue, 1 May 2012 16:05:10 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011605.q41G5Aq9033517@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:05:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234883 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:05:10 -0000 Author: monthadar Date: Tue May 1 16:05:09 2012 New Revision: 234883 URL: http://svn.freebsd.org/changeset/base/234883 Log: * Added a mesh max PREQ retires sysctl that governous how many times we try to discover an address; * Added a mesh net travelse time across an MBSS, which is used to enforce discovery rate check; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:03:27 2012 (r234882) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:05:09 2012 (r234883) @@ -154,7 +154,8 @@ struct ieee80211_hwmp_route { ieee80211_hwmp_seq hr_preqid; /* last PREQ ID seen from dst */ ieee80211_hwmp_seq hr_origseq; /* seq. no. on our latest PREQ*/ struct timeval hr_lastpreq; /* last time we sent a PREQ */ - int hr_preqretries; + int hr_preqretries; /* number of discoveries */ + int hr_lastdiscovery; /* last discovery in ticks */ }; struct ieee80211_hwmp_state { ieee80211_hwmp_seq hs_seq; /* next seq to be used */ @@ -177,6 +178,15 @@ static int ieee80211_hwmp_pathtimeout = SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, pathlifetime, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_pathtimeout, 0, ieee80211_sysctl_msecs_ticks, "I", "path entry lifetime (ms)"); +static int ieee80211_hwmp_maxpreq_retries = -1; +SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, maxpreq_retries, CTLTYPE_INT | CTLFLAG_RW, + &ieee80211_hwmp_maxpreq_retries, 0, ieee80211_sysctl_msecs_ticks, "I", + "maximum number of preq retries"); +static int ieee80211_hwmp_net_diameter_traversaltime = -1; +SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, net_diameter_traversal_time, + CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_net_diameter_traversaltime, 0, + ieee80211_sysctl_msecs_ticks, "I", + "estimate travelse time across the MBSS (ms)"); static int ieee80211_hwmp_roottimeout = -1; SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, roottimeout, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_roottimeout, 0, ieee80211_sysctl_msecs_ticks, "I", @@ -212,10 +222,17 @@ SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, in static void ieee80211_hwmp_init(void) { + /* Default values as per amendment */ ieee80211_hwmp_pathtimeout = msecs_to_ticks(5*1000); ieee80211_hwmp_roottimeout = msecs_to_ticks(5*1000); ieee80211_hwmp_rootint = msecs_to_ticks(2*1000); ieee80211_hwmp_rannint = msecs_to_ticks(1*1000); + ieee80211_hwmp_maxpreq_retries = 3; + /* + * (TU): A measurement of time equal to 1024 μs, + * 500 TU is 512 ms. + */ + ieee80211_hwmp_net_diameter_traversaltime = msecs_to_ticks(512); /* * Register action frame handler. @@ -1288,6 +1305,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric, metric); hr->hr_seq = prep->prep_targetseq; + hr->hr_preqretries = 0; IEEE80211_ADDR_COPY(rt->rt_nexthop, ni->ni_macaddr); rt->rt_metric = metric; rt->rt_nhops = prep->prep_hopcount + 1; @@ -1648,13 +1666,31 @@ hwmp_discover(struct ieee80211vap *vap, hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) { + if (hr->hr_lastdiscovery != 0 && + (ticks - hr->hr_lastdiscovery < + (ieee80211_hwmp_net_diameter_traversaltime * 2))) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + dest, NULL, "%s", + "too frequent discovery requeust"); + /* XXX: stats? */ + goto done; + } + hr->hr_lastdiscovery = ticks; + if (hr->hr_preqretries >= + ieee80211_hwmp_maxpreq_retries) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + dest, NULL, "%s", + "no valid path , max number of discovery"); + vap->iv_stats.is_mesh_fwd_nopath++; + goto done; + } + hr->hr_preqretries++; if (hr->hr_origseq == 0) hr->hr_origseq = ++hs->hs_seq; rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; /* XXX: special discovery timeout, larger lifetime? */ ieee80211_mesh_rt_update(rt, ticks_to_msecs(ieee80211_hwmp_pathtimeout)); - /* XXX check preq retries */ sendpreq = 1; IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest, "start path discovery (src %s), target seq %u", From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:06:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B492D106564A; Tue, 1 May 2012 16:06:21 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 86BB08FC08; Tue, 1 May 2012 16:06:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G6Lkv033597; Tue, 1 May 2012 16:06:21 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G6LJE033594; Tue, 1 May 2012 16:06:21 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011606.q41G6LJE033594@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:06:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234884 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:06:21 -0000 Author: monthadar Date: Tue May 1 16:06:20 2012 New Revision: 234884 URL: http://svn.freebsd.org/changeset/base/234884 Log: * Fixed PREQ flag field Adressing mode subfiled according to amendment specs; Approved by: adria Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:05:09 2012 (r234883) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:06:20 2012 (r234884) @@ -824,7 +824,7 @@ hwmp_rootmode_cb(void *arg) IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, vap->iv_bss, "%s", "send broadcast PREQ"); - preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + preq.preq_flags = 0; if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_PR; if (hs->hs_rootmode == IEEE80211_HWMP_ROOTMODE_PROACTIVE) @@ -1092,8 +1092,8 @@ hwmp_recv_preq(struct ieee80211vap *vap, * Propagate the original PREQ. * PREQ is unicast now to rttarg->rt_nexthop */ - ppreq.preq_flags &= - ~IEEE80211_MESHPREQ_FLAGS_AM; + ppreq.preq_flags |= + IEEE80211_MESHPREQ_FLAGS_AM; ppreq.preq_hopcount += 1; ppreq.preq_ttl -= 1; ppreq.preq_metric += @@ -1701,7 +1701,7 @@ hwmp_discover(struct ieee80211vap *vap, * Try to discover the path for this node. * Group addressed PREQ Case A */ - preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + preq.preq_flags = 0; preq.preq_hopcount = 0; preq.preq_ttl = ms->ms_ttl; preq.preq_id = ++hs->hs_preqid; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:05:09 2012 (r234883) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:06:20 2012 (r234884) @@ -230,7 +230,7 @@ struct ieee80211_meshpreq_ie { uint8_t preq_len; uint8_t preq_flags; #define IEEE80211_MESHPREQ_FLAGS_PR 0x01 /* Portal Role */ -#define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = ucast / 1 = bcast */ +#define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */ #define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */ #define IEEE80211_MESHPREQ_FLAGS_AE 0x40 /* Address Extension */ uint8_t preq_hopcount; From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:07:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05284106564A; Tue, 1 May 2012 16:07:36 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E57178FC18; Tue, 1 May 2012 16:07:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G7Zdv033671; Tue, 1 May 2012 16:07:35 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G7ZKV033668; Tue, 1 May 2012 16:07:35 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011607.q41G7ZKV033668@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:07:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234885 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:07:36 -0000 Author: monthadar Date: Tue May 1 16:07:35 2012 New Revision: 234885 URL: http://svn.freebsd.org/changeset/base/234885 Log: * Fixed hwmp_discover code to populate a PREQ packet correctly; * Removed IEEE80211_MESHPREQ_TFLAGS_RF which is no longer part of the amendment spec; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:06:20 2012 (r234884) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:07:35 2012 (r234885) @@ -171,9 +171,6 @@ static SYSCTL_NODE(_net_wlan, OID_AUTO, static int ieee80211_hwmp_targetonly = 0; SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, targetonly, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_targetonly, 0, "Set TO bit on generated PREQs"); -static int ieee80211_hwmp_replyforward = 1; -SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, replyforward, CTLTYPE_INT | CTLFLAG_RW, - &ieee80211_hwmp_replyforward, 0, "Set RF bit on generated PREQs"); static int ieee80211_hwmp_pathtimeout = -1; SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, pathlifetime, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_pathtimeout, 0, ieee80211_sysctl_msecs_ticks, "I", @@ -838,8 +835,7 @@ hwmp_rootmode_cb(void *arg) preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), broadcastaddr); - PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO | - IEEE80211_MESHPREQ_TFLAGS_RF; + PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO; PREQ_TSEQ(0) = 0; vap->iv_stats.is_hwmp_rootreqs++; hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, @@ -1104,8 +1100,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ ppreq.preq_targets[0].target_flags |= IEEE80211_MESHPREQ_TFLAGS_TO; - ppreq.preq_targets[0].target_flags &= - ~IEEE80211_MESHPREQ_TFLAGS_RF; hwmp_send_preq(ni, vap->iv_myaddr, rttarg->rt_nexthop, &ppreq, &hrtarg->hr_lastpreq, @@ -1709,16 +1703,14 @@ hwmp_discover(struct ieee80211vap *vap, preq.preq_origseq = hr->hr_origseq; preq.preq_lifetime = ticks_to_msecs(ieee80211_hwmp_pathtimeout); - preq.preq_metric = rt->rt_metric; + preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest); PREQ_TFLAGS(0) = 0; if (ieee80211_hwmp_targetonly) PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_TO; - if (ieee80211_hwmp_replyforward) - PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_RF; PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN; - PREQ_TSEQ(0) = hr->hr_seq; + PREQ_TSEQ(0) = 0; /* RESERVED when USN flag is set */ /* XXX check return value */ hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, &hr->hr_lastpreq, Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:06:20 2012 (r234884) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:07:35 2012 (r234885) @@ -246,7 +246,6 @@ struct ieee80211_meshpreq_ie { struct { uint8_t target_flags; #define IEEE80211_MESHPREQ_TFLAGS_TO 0x01 /* Target Only */ -#define IEEE80211_MESHPREQ_TFLAGS_RF 0x02 /* Reply and Forward */ #define IEEE80211_MESHPREQ_TFLAGS_USN 0x04 /* Unknown HWMP seq number */ uint8_t target_addr[IEEE80211_ADDR_LEN]; uint32_t target_seq; /* HWMP Sequence Number */ From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:08:47 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F49D1065677; Tue, 1 May 2012 16:08:47 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2AEA28FC1E; Tue, 1 May 2012 16:08:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G8lmk033748; Tue, 1 May 2012 16:08:47 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G8k9l033746; Tue, 1 May 2012 16:08:46 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011608.q41G8k9l033746@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:08:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234886 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:08:47 -0000 Author: monthadar Date: Tue May 1 16:08:46 2012 New Revision: 234886 URL: http://svn.freebsd.org/changeset/base/234886 Log: * Proactive PREQ (original transmission) must also set IEEE80211_MESHPREQ_TFLAGS_USN flag in target_flag field; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:07:35 2012 (r234885) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:08:46 2012 (r234886) @@ -835,7 +835,8 @@ hwmp_rootmode_cb(void *arg) preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), broadcastaddr); - PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO; + PREQ_TFLAGS(0) = IEEE80211_MESHPREQ_TFLAGS_TO | + IEEE80211_MESHPREQ_TFLAGS_USN; PREQ_TSEQ(0) = 0; vap->iv_stats.is_hwmp_rootreqs++; hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:09:44 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E752B1065673; Tue, 1 May 2012 16:09:44 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D2AE38FC18; Tue, 1 May 2012 16:09:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41G9iTu033811; Tue, 1 May 2012 16:09:44 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41G9inu033809; Tue, 1 May 2012 16:09:44 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011609.q41G9inu033809@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234887 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:09:45 -0000 Author: monthadar Date: Tue May 1 16:09:44 2012 New Revision: 234887 URL: http://svn.freebsd.org/changeset/base/234887 Log: * PREQ acceptance criteria updated to check for proxy condition as in amendment; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:08:46 2012 (r234886) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:09:44 2012 (r234887) @@ -907,13 +907,17 @@ hwmp_recv_preq(struct ieee80211vap *vap, PREQ_TADDR(0), ":"); /* - * Acceptance criteria: if the PREQ is not for us or not broadcast + * Acceptance criteria: (if the PREQ is not for us or not broadcast, + * or an external mac address not proxied by us), * AND forwarding is disabled, discard this PREQ. - * XXX: need to check PROXY */ - if ((!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) || - !IEEE80211_IS_MULTICAST(PREQ_TADDR(0))) && - !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { + rttarg = ieee80211_mesh_rt_find(vap, PREQ_TADDR(0)); + if (!(ms->ms_flags & IEEE80211_MESHFLAGS_FWD) && + (!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) || + !IEEE80211_IS_MULTICAST(PREQ_TADDR(0)) || + (rttarg != NULL && + rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY && + IEEE80211_ADDR_EQ(vap->iv_myaddr, rttarg->rt_mesh_gate)))) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_HWMP, preq->preq_origaddr, NULL, "%s", "not accepting PREQ"); return; @@ -922,7 +926,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, * Acceptance criteria: if unicast addressed * AND no valid forwarding for Target of PREQ, discard this PREQ. */ - rttarg = ieee80211_mesh_rt_find(vap, PREQ_TADDR(0)); if(rttarg != NULL) hrtarg = IEEE80211_MESH_ROUTE_PRIV(rttarg, struct ieee80211_hwmp_route); From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:10:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E78411065680; Tue, 1 May 2012 16:10:32 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D25938FC0A; Tue, 1 May 2012 16:10:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GAWE8033882; Tue, 1 May 2012 16:10:32 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GAWjX033880; Tue, 1 May 2012 16:10:32 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011610.q41GAWjX033880@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:10:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234888 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:10:33 -0000 Author: monthadar Date: Tue May 1 16:10:32 2012 New Revision: 234888 URL: http://svn.freebsd.org/changeset/base/234888 Log: Updated PREQ propagation code; * When receiving a Proactive PREQ dont return after processing it but propagate; * When we propagate we should not enforce ratechecking; * Added checking for multiple pred ID detection; * Storing proxy orig address when PREQ is not for us; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:09:44 2012 (r234887) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:10:32 2012 (r234888) @@ -886,11 +886,13 @@ hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt = NULL; /* pro-active code */ struct ieee80211_mesh_route *rtorig = NULL; + struct ieee80211_mesh_route *rtorig_ext = NULL; struct ieee80211_mesh_route *rttarg = NULL; struct ieee80211_hwmp_route *hrorig = NULL; struct ieee80211_hwmp_route *hrtarg = NULL; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_meshprep_ie prep; + ieee80211_hwmp_seq preqid; /* last seen preqid for orig */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) @@ -945,15 +947,22 @@ hwmp_recv_preq(struct ieee80211vap *vap, rtorig = ieee80211_mesh_rt_find(vap, preq->preq_origaddr); if (rtorig == NULL) { rtorig = ieee80211_mesh_rt_add(vap, preq->preq_origaddr); + if (rtorig == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add orig path to %6D", + preq->preq_origaddr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "adding originator %6D", preq->preq_origaddr, ":"); } - if (rtorig == NULL) { - /* XXX stat */ - return; - } hrorig = IEEE80211_MESH_ROUTE_PRIV(rtorig, struct ieee80211_hwmp_route); + /* record last seen preqid */ + preqid = hrorig->hr_preqid; + hrorig->hr_preqid = HWMP_SEQ_MAX(hrorig->hr_preqid, preq->preq_id); + /* Data creation and update of forwarding information * according to Table 11C-8 for originator mesh STA. */ @@ -968,13 +977,16 @@ hwmp_recv_preq(struct ieee80211vap *vap, ieee80211_mesh_rt_update(rtorig, preq->preq_lifetime); /* path to orig is valid now */ rtorig->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; - }else if(hrtarg != NULL && - HWMP_SEQ_EQ(hrtarg->hr_seq, PREQ_TSEQ(0)) && - (rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) { + }else if ((hrtarg != NULL && + HWMP_SEQ_EQ(hrtarg->hr_seq, PREQ_TSEQ(0)) && + ((rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0)) || + preqid >= preq->preq_id) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "discard PREQ from %6D, old seq no %u <= %u", + "discard PREQ from %6D, old seqno %u <= %u," + " or old preqid %u < %u", preq->preq_origaddr, ":", - preq->preq_origseq, hrorig->hr_seq); + preq->preq_origseq, hrorig->hr_seq, + preq->preq_id, preqid); return; } @@ -1025,6 +1037,26 @@ hwmp_recv_preq(struct ieee80211vap *vap, hwmp_send_prep(ni, vap->iv_myaddr, wh->i_addr2, &prep); return; } + /* we may update our proxy information for the orig external */ + else if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_AE) { + rtorig_ext = + ieee80211_mesh_rt_find(vap, preq->preq_orig_ext_addr); + if (rtorig_ext == NULL) { + rtorig_ext = ieee80211_mesh_rt_add(vap, + preq->preq_orig_ext_addr); + if (rtorig_ext == NULL) { + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add orig ext proxy to %6D", + preq->preq_orig_ext_addr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } + IEEE80211_ADDR_COPY(rtorig_ext->rt_mesh_gate, + preq->preq_origaddr); + } + rtorig_ext->rt_ext_seq = preq->preq_origseq; + ieee80211_mesh_rt_update(rtorig_ext, preq->preq_lifetime); + } /* * Proactive PREQ: reply with a proactive PREP to the * root STA if requested. @@ -1067,54 +1099,29 @@ hwmp_recv_preq(struct ieee80211vap *vap, hwmp_send_prep(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &prep); } - hwmp_discover(vap, rootmac, NULL); - return; } /* * Forwarding and Intermediate reply for PREQs with 1 target. */ - if (preq->preq_tcount == 1) { + if ((preq->preq_tcount == 1) && (preq->preq_ttl > 1) && + (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { struct ieee80211_meshpreq_ie ppreq; /* propagated PREQ */ memcpy(&ppreq, preq, sizeof(ppreq)); + /* * We have a valid route to this node. */ if (rttarg != NULL && (rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { - if (preq->preq_ttl > 1 && - preq->preq_hopcount < hs->hs_maxhops) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "forward PREQ from %6D", - preq->preq_origaddr, ":"); - /* - * Propagate the original PREQ. - * PREQ is unicast now to rttarg->rt_nexthop - */ - ppreq.preq_flags |= - IEEE80211_MESHPREQ_FLAGS_AM; - ppreq.preq_hopcount += 1; - ppreq.preq_ttl -= 1; - ppreq.preq_metric += - ms->ms_pmetric->mpm_metric(ni); - /* - * Set TO and unset RF bits because we are - * going to send a PREP next. - */ - ppreq.preq_targets[0].target_flags |= - IEEE80211_MESHPREQ_TFLAGS_TO; - hwmp_send_preq(ni, vap->iv_myaddr, - rttarg->rt_nexthop, &ppreq, - &hrtarg->hr_lastpreq, - &ieee80211_hwmp_preqminint); - } /* * Check if we can send an intermediate Path Reply, - * i.e., Target Only bit is not set. + * i.e., Target Only bit is not set and target is not + * the MAC broadcast address. */ if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO) && - HWMP_SEQ_GEQ(hrtarg->hr_seq, PREQ_TSEQ(0))) { + !IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr)) { struct ieee80211_meshprep_ie prep; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -1133,42 +1140,26 @@ hwmp_recv_preq(struct ieee80211vap *vap, prep.prep_origseq = hrorig->hr_seq; hwmp_send_prep(ni, vap->iv_myaddr, rtorig->rt_nexthop, &prep); - } - /* - * We have no information about this path, - * propagate the PREQ. - */ - } else if (preq->preq_ttl > 1 && - preq->preq_hopcount < hs->hs_maxhops) { - if (rttarg == NULL) { - rttarg = - ieee80211_mesh_rt_add(vap, PREQ_TADDR(0)); - if (rttarg == NULL) { - IEEE80211_NOTE(vap, - IEEE80211_MSG_HWMP, ni, - "unable to add PREQ path to %6D", - PREQ_TADDR(0), ":"); - vap->iv_stats.is_mesh_rtaddfailed++; - return; - } - } - rttarg->rt_metric = preq->preq_metric; - ieee80211_mesh_rt_update(rttarg, preq->preq_lifetime); - hrtarg = IEEE80211_MESH_ROUTE_PRIV(rttarg, - struct ieee80211_hwmp_route); - hrtarg->hr_seq = PREQ_TSEQ(0); - hrtarg->hr_preqid = preq->preq_id; - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "forward PREQ from %6D", - preq->preq_origaddr, ":"); - ppreq.preq_hopcount += 1; - ppreq.preq_ttl -= 1; - ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); - hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, - &ppreq, &hrtarg->hr_lastpreq, - &ieee80211_hwmp_preqminint); + /* + * Set TO and unset RF bits because we have + * sent a PREP. + */ + ppreq.preq_targets[0].target_flags |= + IEEE80211_MESHPREQ_TFLAGS_TO; + } } + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "forward PREQ from %6D", + preq->preq_origaddr, ":"); + ppreq.preq_hopcount += 1; + ppreq.preq_ttl -= 1; + ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); + + /* don't do PREQ ratecheck when we propagate */ + hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, + &ppreq, NULL, NULL); } } #undef PREQ_TFLAGS From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:11:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8D52E1065677; Tue, 1 May 2012 16:11:48 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6E9E18FC18; Tue, 1 May 2012 16:11:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GBmbF033975; Tue, 1 May 2012 16:11:48 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GBmeN033973; Tue, 1 May 2012 16:11:48 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011611.q41GBmeN033973@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:11:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234889 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:11:48 -0000 Author: monthadar Date: Tue May 1 16:11:47 2012 New Revision: 234889 URL: http://svn.freebsd.org/changeset/base/234889 Log: * Modified PERR acceptance criteria according to amendment; * Modified how PERR is handled and propagated according to amendment; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:10:32 2012 (r234888) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:11:47 2012 (r234889) @@ -1450,7 +1450,7 @@ hwmp_peerdown(struct ieee80211_node *ni) PERR_DFLAGS(0) |= IEEE80211_MESHPERR_DFLAGS_USN; PERR_DFLAGS(0) |= IEEE80211_MESHPERR_DFLAGS_RC; IEEE80211_ADDR_COPY(PERR_DADDR(0), rt->rt_dest); - PERR_DSEQ(0) = hr->hr_seq; + PERR_DSEQ(0) = ++hr->hr_seq; PERR_DRCODE(0) = IEEE80211_REASON_MESH_PERR_DEST_UNREACH; /* NB: flush everything passing through peer */ ieee80211_mesh_rt_flush_peer(vap, ni->ni_macaddr); @@ -1461,60 +1461,117 @@ hwmp_peerdown(struct ieee80211_node *ni) #undef PERR_DSEQ #undef PERR_DRCODE -#define PERR_DFLAGS(n) perr->perr_dests[n].dest_flags -#define PERR_DADDR(n) perr->perr_dests[n].dest_addr -#define PERR_DSEQ(n) perr->perr_dests[n].dest_seq -#define PERR_DRCODE(n) perr->perr_dests[n].dest_rcode +#define PERR_DFLAGS(n) perr->perr_dests[n].dest_flags +#define PERR_DADDR(n) perr->perr_dests[n].dest_addr +#define PERR_DSEQ(n) perr->perr_dests[n].dest_seq +#define PERR_DEXTADDR(n) perr->perr_dests[n].dest_ext_addr +#define PERR_DRCODE(n) perr->perr_dests[n].dest_rcode static void hwmp_recv_perr(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshperr_ie *perr) { struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt = NULL; + struct ieee80211_mesh_route *rt_ext = NULL; struct ieee80211_hwmp_route *hr; - struct ieee80211_meshperr_ie pperr; - int i, forward = 0; + struct ieee80211_meshperr_ie *pperr = NULL; + int i, j = 0, forward = 0; - /* - * Acceptance criteria: check if we received a PERR from a - * neighbor and forwarding is enabled. - */ if (ni == vap->iv_bss || - ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED || - !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) + ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) return; + + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PERR from %6D", wh->i_addr2, ":"); + + /* + * if forwarding is true, prepare pperr + */ + if (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) { + forward = 1; + pperr = malloc(sizeof(*perr) + 31*sizeof(*perr->perr_dests), + M_80211_MESH_PERR, M_NOWAIT); /* XXX: magic number, 32 err dests */ + } + /* - * Find all routing entries that match and delete them. + * Acceptance criteria: check if we have forwarding information + * stored about destination, and that nexthop == TA of this PERR. + * NB: we also build a new PERR to propagate in case we should forward. */ for (i = 0; i < perr->perr_ndests; i++) { rt = ieee80211_mesh_rt_find(vap, PERR_DADDR(i)); - if (rt == NULL) + if (rt == NULL || rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) continue; + if (!IEEE80211_ADDR_EQ(rt->rt_nexthop, wh->i_addr2)) + continue; + + /* found and accepted a PERR ndest element, process it... */ + if (forward) + memcpy(&pperr->perr_dests[j], &perr->perr_dests[i], + sizeof(*perr->perr_dests)); hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); - if (!(PERR_DFLAGS(0) & IEEE80211_MESHPERR_DFLAGS_USN) && - HWMP_SEQ_GEQ(PERR_DSEQ(i), hr->hr_seq)) { - ieee80211_mesh_rt_del(vap, rt->rt_dest); - ieee80211_mesh_rt_flush_peer(vap, rt->rt_dest); - rt = NULL; - forward = 1; + switch(PERR_DFLAGS(i)) { + case (IEEE80211_REASON_MESH_PERR_NO_FI): + if (PERR_DSEQ(i) == 0) { + hr->hr_seq++; + if (forward) { + pperr->perr_dests[j].dest_seq = + hr->hr_seq; + } + } else { + hr->hr_seq = PERR_DSEQ(i); + } + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_VALID; + j++; + break; + case (IEEE80211_REASON_MESH_PERR_DEST_UNREACH): + if(HWMP_SEQ_GT(PERR_DSEQ(i), hr->hr_seq)) { + hr->hr_seq = PERR_DSEQ(i); + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_VALID; + j++; + } + break; + case (IEEE80211_REASON_MESH_PERR_NO_PROXY): + rt_ext = ieee80211_mesh_rt_find(vap, PERR_DEXTADDR(i)); + if (rt_ext != NULL) { + rt_ext->rt_flags &= + ~IEEE80211_MESHRT_FLAGS_VALID; + j++; + } + break; + default: + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "PERR, unknown reason code %u\n", PERR_DFLAGS(i)); + goto done; /* XXX: stats?? */ } + ieee80211_mesh_rt_flush_peer(vap, rt->rt_dest); + KASSERT(j < 32, ("PERR, error ndest >= 32 (%u)", j)); + } + if (j == 0) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, "%s", + "PERR not accepted"); + goto done; /* XXX: stats?? */ } + /* * Propagate the PERR if we previously found it on our routing table. - * XXX handle ndest > 1 */ if (forward && perr->perr_ttl > 1) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "propagate PERR from %6D", wh->i_addr2, ":"); - memcpy(&pperr, perr, sizeof(*perr)); - pperr.perr_ttl--; + pperr->perr_ndests = j; + pperr->perr_ttl--; hwmp_send_perr(vap->iv_bss, vap->iv_myaddr, broadcastaddr, - &pperr); + pperr); } +done: + if (pperr != NULL) + free(pperr, M_80211_MESH_PERR); } #undef PERR_DFLAGS #undef PEER_DADDR #undef PERR_DSEQ +#undef PERR_DEXTADDR #undef PERR_DRCODE static int From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:12:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 712B11065672; Tue, 1 May 2012 16:12:40 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C0F38FC17; Tue, 1 May 2012 16:12:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GCexx034050; Tue, 1 May 2012 16:12:40 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GCeM0034046; Tue, 1 May 2012 16:12:40 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011612.q41GCeM0034046@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:12:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234890 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:12:40 -0000 Author: monthadar Date: Tue May 1 16:12:39 2012 New Revision: 234890 URL: http://svn.freebsd.org/changeset/base/234890 Log: PERR update to be called from mesh code. * Added mpp_senderror for Mesh Path Selection protocol; * Added hwmp_senderror that will send an HWMP PERR according to the supplied reason code; * Call mpp_senderror when deleting a route with correct reason code for whether the route is marked proxy or not; * Call mpp_senderror when trying to forward an individually addressed frame and there is no forwarding information; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:11:47 2012 (r234889) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:12:39 2012 (r234890) @@ -105,6 +105,9 @@ static int hwmp_send_perr(struct ieee802 const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], struct ieee80211_meshperr_ie *); +static void hwmp_senderror(struct ieee80211vap *, + const uint8_t [IEEE80211_ADDR_LEN], + struct ieee80211_mesh_route *, int); static void hwmp_recv_rann(struct ieee80211vap *, struct ieee80211_node *, const struct ieee80211_frame *, const struct ieee80211_meshrann_ie *); @@ -206,6 +209,7 @@ static struct ieee80211_mesh_proto_path .mpp_ie = IEEE80211_MESHCONF_PATH_HWMP, .mpp_discover = hwmp_discover, .mpp_peerdown = hwmp_peerdown, + .mpp_senderror = hwmp_senderror, .mpp_vattach = hwmp_vattach, .mpp_vdetach = hwmp_vdetach, .mpp_newstate = hwmp_newstate, @@ -1569,7 +1573,7 @@ done: free(pperr, M_80211_MESH_PERR); } #undef PERR_DFLAGS -#undef PEER_DADDR +#undef PERR_DADDR #undef PERR_DSEQ #undef PERR_DEXTADDR #undef PERR_DRCODE @@ -1614,6 +1618,64 @@ hwmp_send_perr(struct ieee80211_node *ni return hwmp_send_action(ni, sa, da, (uint8_t *)perr, perr->perr_len+2); } +/* + * Called from the rest of the net80211 code (mesh code for example). + * NB: IEEE80211_REASON_MESH_PERR_DEST_UNREACH can be trigger by the fact that + * a mesh STA is unable to forward an MSDU/MMPDU to a next-hop mesh STA. + */ +#define PERR_DFLAGS(n) perr.perr_dests[n].dest_flags +#define PERR_DADDR(n) perr.perr_dests[n].dest_addr +#define PERR_DSEQ(n) perr.perr_dests[n].dest_seq +#define PERR_DEXTADDR(n) perr.perr_dests[n].dest_ext_addr +#define PERR_DRCODE(n) perr.perr_dests[n].dest_rcode +static void +hwmp_senderror(struct ieee80211vap *vap, + const uint8_t addr[IEEE80211_ADDR_LEN], + struct ieee80211_mesh_route *rt, int rcode) +{ + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_hwmp_route *hr = NULL; + struct ieee80211_meshperr_ie perr; + + if (rt != NULL) + hr = IEEE80211_MESH_ROUTE_PRIV(rt, + struct ieee80211_hwmp_route); + + perr.perr_ndests = 1; + perr.perr_ttl = ms->ms_ttl; + PERR_DFLAGS(0) = 0; + PERR_DRCODE(0) = rcode; + + switch (rcode) { + case IEEE80211_REASON_MESH_PERR_NO_FI: + IEEE80211_ADDR_COPY(PERR_DADDR(0), addr); + PERR_DSEQ(0) = 0; /* reserved */ + break; + case IEEE80211_REASON_MESH_PERR_NO_PROXY: + KASSERT(rt != NULL, ("no proxy info for sending PERR")); + KASSERT(rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY, + ("route is not marked proxy")); + PERR_DFLAGS(0) |= IEEE80211_MESHPERR_FLAGS_AE; + IEEE80211_ADDR_COPY(PERR_DADDR(0), vap->iv_myaddr); + PERR_DSEQ(0) = rt->rt_ext_seq; + IEEE80211_ADDR_COPY(PERR_DEXTADDR(0), addr); + break; + case IEEE80211_REASON_MESH_PERR_DEST_UNREACH: + KASSERT(rt != NULL, ("no route info for sending PERR")); + IEEE80211_ADDR_COPY(PERR_DADDR(0), addr); + PERR_DSEQ(0) = hr->hr_seq; + break; + default: + KASSERT(0, ("unknown reason code for HWMP PERR (%u)", rcode)); + } + hwmp_send_perr(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &perr); +} +#undef PERR_DFLAGS +#undef PEER_DADDR +#undef PERR_DSEQ +#undef PERR_DEXTADDR +#undef PERR_DRCODE + static void hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshrann_ie *rann) Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:11:47 2012 (r234889) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:12:39 2012 (r234890) @@ -344,6 +344,13 @@ ieee80211_mesh_rt_del(struct ieee80211va MESH_RT_LOCK(ms); TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) { if (IEEE80211_ADDR_EQ(rt->rt_dest, dest)) { + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { + ms->ms_ppath->mpp_senderror(vap, dest, rt, + IEEE80211_REASON_MESH_PERR_NO_PROXY); + } else { + ms->ms_ppath->mpp_senderror(vap, dest, rt, + IEEE80211_REASON_MESH_PERR_DEST_UNREACH); + } mesh_rt_del(ms, rt); MESH_RT_UNLOCK(ms); return; @@ -972,10 +979,12 @@ mesh_forward(struct ieee80211vap *vap, s * [Optional] any of the following three actions: * o silently discard * o trigger a path discovery - * o inform TA that meshDA is unreachable. + * o inform TA that meshDA is unknown. */ IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_MESH, wh, "%s", "frame not fwd'd, no path"); + ms->ms_ppath->mpp_senderror(vap, whcopy->i_addr3, NULL, + IEEE80211_REASON_MESH_PERR_NO_FI); vap->iv_stats.is_mesh_fwd_nopath++; m_freem(mcopy); return; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:11:47 2012 (r234889) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:12:39 2012 (r234890) @@ -449,6 +449,9 @@ struct ieee80211_mesh_proto_path { const uint8_t [IEEE80211_ADDR_LEN], struct mbuf *); void (*mpp_peerdown)(struct ieee80211_node *); + void (*mpp_senderror)(struct ieee80211vap *, + const uint8_t [IEEE80211_ADDR_LEN], + struct ieee80211_mesh_route *, int); void (*mpp_vattach)(struct ieee80211vap *); void (*mpp_vdetach)(struct ieee80211vap *); int (*mpp_newstate)(struct ieee80211vap *, From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:13:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAE8B106566B; Tue, 1 May 2012 16:13:22 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4E948FC18; Tue, 1 May 2012 16:13:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GDMBd034117; Tue, 1 May 2012 16:13:22 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GDMtT034114; Tue, 1 May 2012 16:13:22 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011613.q41GDMtT034114@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:13:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234891 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:13:22 -0000 Author: monthadar Date: Tue May 1 16:13:22 2012 New Revision: 234891 URL: http://svn.freebsd.org/changeset/base/234891 Log: RANN update * Introduced a new HWMP sysctl, Root Confirmation Interval; * Added hr_lastrootconf to hwmp_route, is for ratecheck for a specific ROOT; * We missed reading RANN.interval subfield from a RANN frame before; * Updated hwmp_recv_rann according to amendment, see comments; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:12:39 2012 (r234890) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:13:22 2012 (r234891) @@ -157,6 +157,7 @@ struct ieee80211_hwmp_route { ieee80211_hwmp_seq hr_preqid; /* last PREQ ID seen from dst */ ieee80211_hwmp_seq hr_origseq; /* seq. no. on our latest PREQ*/ struct timeval hr_lastpreq; /* last time we sent a PREQ */ + struct timeval hr_lastrootconf; /* last sent PREQ root conf */ int hr_preqretries; /* number of discoveries */ int hr_lastdiscovery; /* last discovery in ticks */ }; @@ -199,6 +200,11 @@ static int ieee80211_hwmp_rannint = -1; SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, rannint, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_rannint, 0, ieee80211_sysctl_msecs_ticks, "I", "root announcement interval (ms)"); +static struct timeval ieee80211_hwmp_rootconfint = { 0, 0 }; +static int ieee80211_hwmp_rootconfint_internal = -1; +SYSCTL_PROC(_net_wlan_hwmp, OID_AUTO, rootconfint, CTLTYPE_INT | CTLFLAG_RD, + &ieee80211_hwmp_rootconfint_internal, 0, ieee80211_sysctl_msecs_ticks, "I", + "root confirmation interval (ms) (read-only)"); #define IEEE80211_HWMP_DEFAULT_MAXHOPS 31 @@ -228,6 +234,7 @@ ieee80211_hwmp_init(void) ieee80211_hwmp_roottimeout = msecs_to_ticks(5*1000); ieee80211_hwmp_rootint = msecs_to_ticks(2*1000); ieee80211_hwmp_rannint = msecs_to_ticks(1*1000); + ieee80211_hwmp_rootconfint_internal = msecs_to_ticks(2*1000); ieee80211_hwmp_maxpreq_retries = 3; /* * (TU): A measurement of time equal to 1024 μs, @@ -236,6 +243,13 @@ ieee80211_hwmp_init(void) ieee80211_hwmp_net_diameter_traversaltime = msecs_to_ticks(512); /* + * NB: I dont know how to make SYSCTL_PROC that calls ms to ticks + * and return a struct timeval... + */ + ieee80211_hwmp_rootconfint.tv_usec = + ieee80211_hwmp_rootconfint_internal * 1000; + + /* * Register action frame handler. */ ieee80211_recv_action_register(IEEE80211_ACTION_CAT_MESH, @@ -555,6 +569,7 @@ hwmp_recv_action_meshpath(struct ieee802 } memcpy(&rann, mrann, sizeof(rann)); rann.rann_seq = LE_READ_4(&mrann->rann_seq); + rann.rann_interval = LE_READ_4(&mrann->rann_interval); rann.rann_metric = LE_READ_4(&mrann->rann_metric); hwmp_recv_rann(vap, ni, wh, &rann); found++; @@ -873,6 +888,7 @@ hwmp_rootmode_rann_cb(void *arg) rann.rann_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(rann.rann_addr, vap->iv_myaddr); rann.rann_seq = ++hs->hs_seq; + rann.rann_interval = ieee80211_hwmp_rannint; rann.rann_metric = IEEE80211_MESHLMETRIC_INITIALVAL; vap->iv_stats.is_hwmp_rootrann++; @@ -1684,7 +1700,9 @@ hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_mesh_route *rt = NULL; struct ieee80211_hwmp_route *hr; + struct ieee80211_meshpreq_ie preq; struct ieee80211_meshrann_ie prann; + uint32_t metric = 0; if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED || @@ -1692,27 +1710,74 @@ hwmp_recv_rann(struct ieee80211vap *vap, return; rt = ieee80211_mesh_rt_find(vap, rann->rann_addr); - /* - * Discover the path to the root mesh STA. - * If we already know it, propagate the RANN element. - */ + if (rt != NULL && rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) { + hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + + /* Acceptance criteria: if RANN.seq < stored seq, discard RANN */ + if (HWMP_SEQ_LT(rann->rann_seq, hr->hr_seq)) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "RANN seq %u < %u", rann->rann_seq, hr->hr_seq); + return; + } + + /* Acceptance criteria: if RANN.seq == stored seq AND + * RANN.metric > stored metric, discard RANN */ + if (HWMP_SEQ_EQ(rann->rann_seq, hr->hr_seq) && + rann->rann_metric > rt->rt_metric) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "RANN metric %u > %u", rann->rann_metric, rt->rt_metric); + return; + } + } + + /* RANN ACCEPTED */ + + ieee80211_hwmp_rannint = rann->rann_interval; /* XXX: mtx lock? */ + metric = rann->rann_metric + ms->ms_pmetric->mpm_metric(ni); + if (rt == NULL) { - hwmp_discover(vap, rann->rann_addr, NULL); - return; + rt = ieee80211_mesh_rt_add(vap, rann->rann_addr); + if (rt == NULL) { + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "unable to add mac for RANN root %6D", + rann->rann_addr, ":"); + vap->iv_stats.is_mesh_rtaddfailed++; + return; + } } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); - if (HWMP_SEQ_GT(rann->rann_seq, hr->hr_seq)) { + /* discovery timeout */ + ieee80211_mesh_rt_update(rt, + ticks_to_msecs(ieee80211_hwmp_roottimeout)); + + preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + preq.preq_hopcount = 0; + preq.preq_ttl = ms->ms_ttl; + preq.preq_id = 0; /* reserved */ + IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); + preq.preq_origseq = ++hs->hs_seq; + preq.preq_lifetime = ieee80211_hwmp_roottimeout; + preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; + preq.preq_tcount = 1; + preq.preq_targets[0].target_flags = IEEE80211_MESHPREQ_TFLAGS_TO; + /* NB: IEEE80211_MESHPREQ_TFLAGS_USN = 0 implicitly implied */ + IEEE80211_ADDR_COPY(preq.preq_targets[0].target_addr, rann->rann_addr); + preq.preq_targets[0].target_seq = rann->rann_seq; + /* XXX: if rootconfint have not passed, we built this preq in vain */ + hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, wh->i_addr2, &preq, + &hr->hr_lastrootconf, &ieee80211_hwmp_rootconfint); + + /* propagate a RANN */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID && + rann->rann_ttl > 1 && + ms->ms_flags & IEEE80211_MESHFLAGS_FWD) { hr->hr_seq = rann->rann_seq; - if (rann->rann_ttl > 1 && - rann->rann_hopcount < hs->hs_maxhops && - (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { - memcpy(&prann, rann, sizeof(prann)); - prann.rann_hopcount += 1; - prann.rann_ttl -= 1; - prann.rann_metric += ms->ms_pmetric->mpm_metric(ni); - hwmp_send_rann(vap->iv_bss, vap->iv_myaddr, - broadcastaddr, &prann); - } + memcpy(&prann, rann, sizeof(prann)); + prann.rann_hopcount += 1; + prann.rann_ttl -= 1; + prann.rann_metric += ms->ms_pmetric->mpm_metric(ni); + hwmp_send_rann(vap->iv_bss, vap->iv_myaddr, + broadcastaddr, &prann); } } Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:12:39 2012 (r234890) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:13:22 2012 (r234891) @@ -426,7 +426,7 @@ struct ieee80211_mesh_route { uint32_t rt_metric; /* path metric */ uint16_t rt_nhops; /* number of hops */ uint16_t rt_flags; -#define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* patch discovery complete */ +#define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* path discovery complete */ #define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:14:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 188451065672; Tue, 1 May 2012 16:14:19 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 03B278FC12; Tue, 1 May 2012 16:14:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GEI12034197; Tue, 1 May 2012 16:14:18 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GEISi034191; Tue, 1 May 2012 16:14:18 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011614.q41GEISi034191@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:14:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234892 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:14:19 -0000 Author: monthadar Date: Tue May 1 16:14:18 2012 New Revision: 234892 URL: http://svn.freebsd.org/changeset/base/234892 Log: Net80211s update: Mesh Gate Announcement and removal of Portal Announcement. * Renamed IEEE80211_ELEMID_MESHPANN to IEEE80211_ELEMID_MESHGANN according to amendment; * Added IEEE80211_IOC_MESH_GATE that controls whether Mesh Gate Announcement is activated or not; * Renamed all flags from Portal to Gate in HWMP frames; * Removed IEEE80211_ACTION_MESHPANN enum cause its part of the Mesh Action category now as per amendment; * Renamed IEEE80211_MESHFLAGS_PORTAL to IEEE80211_MESHFLAGS_GATE in ieee80211_mesh_state flags; * Modified ieee80211_hwmp.c/ieee80211_mesh.c to use new GATE flags; Approved by: adrian Modified: head/sys/net80211/ieee80211.h head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_ioctl.h head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211.h ============================================================================== --- head/sys/net80211/ieee80211.h Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211.h Tue May 1 16:14:18 2012 (r234892) @@ -734,7 +734,7 @@ enum { IEEE80211_ELEMID_MESHAWAKEW = 119, IEEE80211_ELEMID_MESHBEACONT = 120, /* 121-124 MMCAOP not implemented yet */ - IEEE80211_ELEMID_MESHPANN = 125, /* XXX: is GANN now, not used */ + IEEE80211_ELEMID_MESHGANN = 125, IEEE80211_ELEMID_MESHRANN = 126, /* 127 Extended Capabilities */ /* 128-129 reserved */ Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:14:18 2012 (r234892) @@ -840,9 +840,9 @@ hwmp_rootmode_cb(void *arg) IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, vap->iv_bss, "%s", "send broadcast PREQ"); - preq.preq_flags = 0; - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) - preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_PR; + preq.preq_flags = IEEE80211_MESHPREQ_FLAGS_AM; + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) + preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_GATE; if (hs->hs_rootmode == IEEE80211_HWMP_ROOTMODE_PROACTIVE) preq.preq_flags |= IEEE80211_MESHPREQ_FLAGS_PP; preq.preq_hopcount = 0; @@ -882,8 +882,8 @@ hwmp_rootmode_rann_cb(void *arg) "%s", "send broadcast RANN"); rann.rann_flags = 0; - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) - rann.rann_flags |= IEEE80211_MESHRANN_FLAGS_PR; + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) + rann.rann_flags |= IEEE80211_MESHFLAGS_GATE; rann.rann_hopcount = 0; rann.rann_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(rann.rann_addr, vap->iv_myaddr); Modified: head/sys/net80211/ieee80211_ioctl.h ============================================================================== --- head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:14:18 2012 (r234892) @@ -709,6 +709,7 @@ struct ieee80211req { #define IEEE80211_IOC_MESH_PR_SIG 178 /* mesh sig protocol */ #define IEEE80211_IOC_MESH_PR_CC 179 /* mesh congestion protocol */ #define IEEE80211_IOC_MESH_PR_AUTH 180 /* mesh auth protocol */ +#define IEEE80211_IOC_MESH_GATE 181 /* mesh gate XXX: 173? */ #define IEEE80211_IOC_HWMP_ROOTMODE 190 /* HWMP root mode */ #define IEEE80211_IOC_HWMP_MAXHOPS 191 /* number of hops before drop */ Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:14:18 2012 (r234892) @@ -1262,7 +1262,7 @@ mesh_recv_group_data(struct ieee80211vap * This happens by delivering the packet, and a bridge * will sent it on another port member. */ - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL && + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE && ms->ms_flags & IEEE80211_MESHFLAGS_FWD) IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, MC01(mc)->mc_addr4, "%s", @@ -2768,8 +2768,8 @@ ieee80211_add_meshconf(uint8_t *frm, str /* NB: set the number of neighbors before the rest */ *frm = (ms->ms_neighbors > IEEE80211_MESH_MAX_NEIGHBORS ? IEEE80211_MESH_MAX_NEIGHBORS : ms->ms_neighbors) << 1; - if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) - *frm |= IEEE80211_MESHCONF_FORM_MP; + if (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) + *frm |= IEEE80211_MESHCONF_FORM_GATE; frm += 1; caps = 0; if (ms->ms_flags & IEEE80211_MESHFLAGS_AP) @@ -2961,6 +2961,9 @@ mesh_ioctl_get80211(struct ieee80211vap case IEEE80211_IOC_MESH_FWRD: ireq->i_val = (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) != 0; break; + case IEEE80211_IOC_MESH_GATE: + ireq->i_val = (ms->ms_flags & IEEE80211_MESHFLAGS_GATE) != 0; + break; case IEEE80211_IOC_MESH_TTL: ireq->i_val = ms->ms_ttl; break; @@ -3076,6 +3079,12 @@ mesh_ioctl_set80211(struct ieee80211vap else ms->ms_flags &= ~IEEE80211_MESHFLAGS_FWD; break; + case IEEE80211_IOC_MESH_GATE: + if (ireq->i_val) + ms->ms_flags |= IEEE80211_MESHFLAGS_GATE; + else + ms->ms_flags &= ~IEEE80211_MESHFLAGS_GATE; + break; case IEEE80211_IOC_MESH_TTL: ms->ms_ttl = (uint8_t) ireq->i_val; break; Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:13:22 2012 (r234891) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:14:18 2012 (r234892) @@ -98,7 +98,7 @@ enum { }; /* Mesh Formation Info */ -#define IEEE80211_MESHCONF_FORM_MP 0x01 /* Connected to Portal */ +#define IEEE80211_MESHCONF_FORM_GATE 0x01 /* Connected to Gate */ #define IEEE80211_MESHCONF_FORM_NNEIGH_MASK 0x7E /* Number of Neighbours */ #define IEEE80211_MESHCONF_FORM_SA 0xF0 /* indicating 802.1X auth */ @@ -193,9 +193,9 @@ struct ieee80211_meshbeacont_ie { } __packed; #endif -/* Portal (MP) Annoucement */ -struct ieee80211_meshpann_ie { - uint8_t pann_ie; /* IEEE80211_ELEMID_MESHPANN */ +/* Gate (GANN) Annoucement */ +struct ieee80211_meshgann_ie { + uint8_t pann_ie; /* IEEE80211_ELEMID_MESHGANN */ uint8_t pann_len; uint8_t pann_flags; uint8_t pann_hopcount; @@ -210,7 +210,7 @@ struct ieee80211_meshrann_ie { uint8_t rann_ie; /* IEEE80211_ELEMID_MESHRANN */ uint8_t rann_len; uint8_t rann_flags; -#define IEEE80211_MESHRANN_FLAGS_PR 0x01 /* Portal Role */ +#define IEEE80211_MESHRANN_FLAGS_GATE 0x01 /* Mesh Gate */ uint8_t rann_hopcount; uint8_t rann_ttl; uint8_t rann_addr[IEEE80211_ADDR_LEN]; @@ -229,7 +229,7 @@ struct ieee80211_meshpreq_ie { uint8_t preq_ie; /* IEEE80211_ELEMID_MESHPREQ */ uint8_t preq_len; uint8_t preq_flags; -#define IEEE80211_MESHPREQ_FLAGS_PR 0x01 /* Portal Role */ +#define IEEE80211_MESHPREQ_FLAGS_GATE 0x01 /* Mesh Gate */ #define IEEE80211_MESHPREQ_FLAGS_AM 0x02 /* 0 = bcast / 1 = ucast */ #define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */ #define IEEE80211_MESHPREQ_FLAGS_AE 0x40 /* Address Extension */ @@ -360,14 +360,6 @@ enum { }; /* - * Mesh Portal Annoucement Action codes. - */ -enum { - IEEE80211_ACTION_MESHPANN = 0, - /* 1-255 reserved */ -}; - -/* * Different mesh control structures based on the AE * (Address Extension) bits. */ @@ -498,7 +490,7 @@ struct ieee80211_mesh_state { uint16_t ms_neighbors; uint8_t ms_ttl; /* mesh ttl set in packets */ #define IEEE80211_MESHFLAGS_AP 0x01 /* accept peers */ -#define IEEE80211_MESHFLAGS_PORTAL 0x02 /* mesh portal role */ +#define IEEE80211_MESHFLAGS_GATE 0x02 /* mesh gate role */ #define IEEE80211_MESHFLAGS_FWD 0x04 /* forward packets */ uint8_t ms_flags; struct mtx ms_rt_lock; @@ -556,7 +548,7 @@ ieee80211_mesh_isproxyena(struct ieee802 { struct ieee80211_mesh_state *ms = vap->iv_mesh; return (ms->ms_flags & - (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_PORTAL)) != 0; + (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_GATE)) != 0; } /* From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:15:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C1D87106581A; Tue, 1 May 2012 16:15:35 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9292C8FC16; Tue, 1 May 2012 16:15:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GFZJv034281; Tue, 1 May 2012 16:15:35 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GFZa1034278; Tue, 1 May 2012 16:15:35 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011615.q41GFZa1034278@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234893 - head/sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:15:35 -0000 Author: monthadar Date: Tue May 1 16:15:34 2012 New Revision: 234893 URL: http://svn.freebsd.org/changeset/base/234893 Log: * Added new command to ifconfig to activate Mesh Gate Announcement called meshgate with corresponding explanation; Approved by: adrian Modified: head/sbin/ifconfig/ifconfig.8 head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Tue May 1 16:14:18 2012 (r234892) +++ head/sbin/ifconfig/ifconfig.8 Tue May 1 16:15:34 2012 (r234893) @@ -1979,6 +1979,12 @@ Enable or disable forwarding packets by By default .Cm meshforward is enabled. +.It Cm meshgate +This attribute specifies whether or not the mesh STA activates mesh gate +announcements. +By default +.Cm meshgate +is disabled. .It Cm meshmetric Ar protocol Set the specified .Ar protocol Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Tue May 1 16:14:18 2012 (r234892) +++ head/sbin/ifconfig/ifieee80211.c Tue May 1 16:15:34 2012 (r234893) @@ -1883,6 +1883,12 @@ DECL_CMD_FUNC(set80211meshforward, val, } static +DECL_CMD_FUNC(set80211meshgate, val, d) +{ + set80211(s, IEEE80211_IOC_MESH_GATE, d, 0, NULL); +} + +static DECL_CMD_FUNC(set80211meshpeering, val, d) { set80211(s, IEEE80211_IOC_MESH_AP, d, 0, NULL); @@ -4832,6 +4838,12 @@ end: else LINE_CHECK("-meshforward"); } + if (get80211val(s, IEEE80211_IOC_MESH_GATE, &val) != -1) { + if (val) + LINE_CHECK("meshgate"); + else + LINE_CHECK("-meshgate"); + } if (get80211len(s, IEEE80211_IOC_MESH_PR_METRIC, data, 12, &len) != -1) { data[len] = '\0'; @@ -5271,6 +5283,8 @@ static struct cmd ieee80211_cmds[] = { DEF_CMD_ARG("meshttl", set80211meshttl), DEF_CMD("meshforward", 1, set80211meshforward), DEF_CMD("-meshforward", 0, set80211meshforward), + DEF_CMD("meshgate", 1, set80211meshgate), + DEF_CMD("-meshgate", 0, set80211meshgate), DEF_CMD("meshpeering", 1, set80211meshpeering), DEF_CMD("-meshpeering", 0, set80211meshpeering), DEF_CMD_ARG("meshmetric", set80211meshmetric), From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:16:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28C5E106567B; Tue, 1 May 2012 16:16:21 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 12D3D8FC20; Tue, 1 May 2012 16:16:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GGKrE034352; Tue, 1 May 2012 16:16:20 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GGKN7034347; Tue, 1 May 2012 16:16:20 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011616.q41GGKN7034347@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:16:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234894 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:16:21 -0000 Author: monthadar Date: Tue May 1 16:16:20 2012 New Revision: 234894 URL: http://svn.freebsd.org/changeset/base/234894 Log: PREQ discovery update. * Added a new discovery flag IEEE80211_MESHRT_FLAGS_DISCOVER; * Modified ieee80211_ioctl.h to include IEEE80211_MESHRT_FLAGS_DISCOVER; * Added hwmp_rediscover_cb, which will be called by a timeout to do rediscovery if we have not reach max number of preq discovery; * Modified hwmp_discover to setup a callout for path rediscovery; * Added to ieee80211req_mesh_route to have a back pointer to ieee80211vap for the discovery callout context; * Modified mesh_rt_add_locked arguemnt from ieee80211_mesh_state to ieee80211vap, this because we have to initialize the above back pointer; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c head/sys/net80211/ieee80211_ioctl.h head/sys/net80211/ieee80211_mesh.c head/sys/net80211/ieee80211_mesh.h Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:16:20 2012 (r234894) @@ -1319,7 +1319,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric = metric; rt->rt_nhops = prep->prep_hopcount + 1; ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ + rt->rt_flags = IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ /* * If it's NOT for us, propagate the PREP @@ -1805,6 +1805,64 @@ hwmp_send_rann(struct ieee80211_node *ni #define PREQ_TFLAGS(n) preq.preq_targets[n].target_flags #define PREQ_TADDR(n) preq.preq_targets[n].target_addr #define PREQ_TSEQ(n) preq.preq_targets[n].target_seq +static void +hwmp_rediscover_cb(void *arg) +{ + struct ieee80211_mesh_route *rt = arg; + struct ieee80211vap *vap = rt->rt_vap; + struct ieee80211_hwmp_state *hs = vap->iv_hwmp; + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_hwmp_route *hr; + struct ieee80211_meshpreq_ie preq; /* Optimize: storing first preq? */ + + if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) + return ; /* nothing to do */ + + hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + if (hr->hr_preqretries >= + ieee80211_hwmp_maxpreq_retries) { + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, + rt->rt_dest, NULL, "%s", + "no valid path , max number of discovery, send GATE"); + /* TODO: send to known gates */ + vap->iv_stats.is_mesh_fwd_nopath++; + rt->rt_flags = 0; /* Mark invalid */ + return ; /* XXX: flush queue? */ + } + + hr->hr_preqretries++; + + + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, rt->rt_dest, + "start path rediscovery , target seq %u", hr->hr_seq); + /* + * Try to discover the path for this node. + * Group addressed PREQ Case A + */ + preq.preq_flags = 0; + preq.preq_hopcount = 0; + preq.preq_ttl = ms->ms_ttl; + preq.preq_id = ++hs->hs_preqid; + IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); + preq.preq_origseq = hr->hr_origseq; + preq.preq_lifetime = ticks_to_msecs(ieee80211_hwmp_pathtimeout); + preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL; + preq.preq_tcount = 1; + IEEE80211_ADDR_COPY(PREQ_TADDR(0), rt->rt_dest); + PREQ_TFLAGS(0) = 0; + if (ieee80211_hwmp_targetonly) + PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_TO; + PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN; + PREQ_TSEQ(0) = 0; /* RESERVED when USN flag is set */ + /* XXX check return value */ + hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, + broadcastaddr, &preq, &hr->hr_lastpreq, + &ieee80211_hwmp_preqminint); + callout_reset(&rt->rt_discovery, + ieee80211_hwmp_net_diameter_traversaltime * 2, + hwmp_rediscover_cb, rt); +} + static struct ieee80211_node * hwmp_discover(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m) @@ -1857,13 +1915,11 @@ hwmp_discover(struct ieee80211vap *vap, vap->iv_stats.is_mesh_fwd_nopath++; goto done; } + rt->rt_flags = IEEE80211_MESHRT_FLAGS_DISCOVER; hr->hr_preqretries++; if (hr->hr_origseq == 0) hr->hr_origseq = ++hs->hs_seq; rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; - /* XXX: special discovery timeout, larger lifetime? */ - ieee80211_mesh_rt_update(rt, - ticks_to_msecs(ieee80211_hwmp_pathtimeout)); sendpreq = 1; IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, dest, "start path discovery (src %s), target seq %u", @@ -1894,6 +1950,9 @@ hwmp_discover(struct ieee80211vap *vap, hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq, &hr->hr_lastpreq, &ieee80211_hwmp_preqminint); + callout_reset(&rt->rt_discovery, + ieee80211_hwmp_net_diameter_traversaltime * 2, + hwmp_rediscover_cb, rt); } if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) ni = ieee80211_find_txnode(vap, rt->rt_nexthop); Modified: head/sys/net80211/ieee80211_ioctl.h ============================================================================== --- head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_ioctl.h Tue May 1 16:16:20 2012 (r234894) @@ -339,8 +339,9 @@ enum { struct ieee80211req_mesh_route { uint8_t imr_flags; -#define IEEE80211_MESHRT_FLAGS_VALID 0x01 -#define IEEE80211_MESHRT_FLAGS_PROXY 0x02 +#define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 +#define IEEE80211_MESHRT_FLAGS_VALID 0x02 +#define IEEE80211_MESHRT_FLAGS_PROXY 0x04 uint8_t imr_dest[IEEE80211_ADDR_LEN]; uint8_t imr_nexthop[IEEE80211_ADDR_LEN]; uint16_t imr_nhops; Modified: head/sys/net80211/ieee80211_mesh.c ============================================================================== --- head/sys/net80211/ieee80211_mesh.c Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_mesh.c Tue May 1 16:16:20 2012 (r234894) @@ -175,9 +175,10 @@ mesh_rt_find_locked(struct ieee80211_mes } static struct ieee80211_mesh_route * -mesh_rt_add_locked(struct ieee80211_mesh_state *ms, +mesh_rt_add_locked(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN]) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_mesh_route *rt; KASSERT(!IEEE80211_ADDR_EQ(broadcastaddr, dest), @@ -188,9 +189,11 @@ mesh_rt_add_locked(struct ieee80211_mesh rt = malloc(ALIGN(sizeof(struct ieee80211_mesh_route)) + ms->ms_ppath->mpp_privlen, M_80211_MESH_RT, M_NOWAIT | M_ZERO); if (rt != NULL) { + rt->rt_vap = vap; IEEE80211_ADDR_COPY(rt->rt_dest, dest); rt->rt_priv = (void *)ALIGN(&rt[1]); mtx_init(&rt->rt_lock, "MBSS_RT", "802.11s route entry", MTX_DEF); + callout_init(&rt->rt_discovery, CALLOUT_MPSAFE); rt->rt_updtime = ticks; /* create time */ TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next); } @@ -223,7 +226,7 @@ ieee80211_mesh_rt_add(struct ieee80211va ("%s: adding self to the routing table", __func__)); MESH_RT_LOCK(ms); - rt = mesh_rt_add_locked(ms, dest); + rt = mesh_rt_add_locked(vap, dest); MESH_RT_UNLOCK(ms); return rt; } @@ -285,7 +288,7 @@ ieee80211_mesh_proxy_check(struct ieee80 MESH_RT_LOCK(ms); rt = mesh_rt_find_locked(ms, dest); if (rt == NULL) { - rt = mesh_rt_add_locked(ms, dest); + rt = mesh_rt_add_locked(vap, dest); if (rt == NULL) { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest, "%s", "unable to add proxy entry"); @@ -330,6 +333,7 @@ mesh_rt_del(struct ieee80211_mesh_state * is holding the route. */ RT_ENTRY_LOCK(rt); + callout_drain(&rt->rt_discovery); mtx_destroy(&rt->rt_lock); free(rt, M_80211_MESH_RT); } @@ -402,13 +406,11 @@ mesh_rt_flush_invalid(struct ieee80211va return; MESH_RT_LOCK(ms); TAILQ_FOREACH_SAFE(rt, &ms->ms_routes, rt_next, next) { + /* Discover paths will be deleted by their own callout */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) + continue; ieee80211_mesh_rt_update(rt, 0); - /* - * NB: we check for lifetime == 0 so that we give a chance - * for route discovery to complete. - */ - if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 && - rt->rt_lifetime == 0) + if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) mesh_rt_del(ms, rt); } MESH_RT_UNLOCK(ms); Modified: head/sys/net80211/ieee80211_mesh.h ============================================================================== --- head/sys/net80211/ieee80211_mesh.h Tue May 1 16:15:34 2012 (r234893) +++ head/sys/net80211/ieee80211_mesh.h Tue May 1 16:16:20 2012 (r234894) @@ -410,7 +410,9 @@ MALLOC_DECLARE(M_80211_MESH_RT); */ struct ieee80211_mesh_route { TAILQ_ENTRY(ieee80211_mesh_route) rt_next; + struct ieee80211vap *rt_vap; struct mtx rt_lock; /* fine grained route lock */ + struct callout rt_discovery; /* discovery timeout */ int rt_updtime; /* last update time */ uint8_t rt_dest[IEEE80211_ADDR_LEN]; uint8_t rt_mesh_gate[IEEE80211_ADDR_LEN]; /* meshDA */ @@ -418,8 +420,9 @@ struct ieee80211_mesh_route { uint32_t rt_metric; /* path metric */ uint16_t rt_nhops; /* number of hops */ uint16_t rt_flags; -#define IEEE80211_MESHRT_FLAGS_VALID 0x01 /* path discovery complete */ -#define IEEE80211_MESHRT_FLAGS_PROXY 0x02 /* proxy entry */ +#define IEEE80211_MESHRT_FLAGS_DISCOVER 0x01 /* path discovery */ +#define IEEE80211_MESHRT_FLAGS_VALID 0x02 /* path discovery complete */ +#define IEEE80211_MESHRT_FLAGS_PROXY 0x04 /* proxy entry */ uint32_t rt_lifetime; /* route timeout */ uint32_t rt_lastmseq; /* last seq# seen dest */ uint32_t rt_ext_seq; /* proxy seq number */ From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:17:18 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F92D1065672; Tue, 1 May 2012 16:17:18 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B75F8FC22; Tue, 1 May 2012 16:17:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GHI0J034421; Tue, 1 May 2012 16:17:18 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GHIbO034418; Tue, 1 May 2012 16:17:18 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011617.q41GHIbO034418@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:17:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234895 - head/sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:17:18 -0000 Author: monthadar Date: Tue May 1 16:17:17 2012 New Revision: 234895 URL: http://svn.freebsd.org/changeset/base/234895 Log: * Modified ifconfig to show the IEEE80211_MESHRT_FLAGS_DISCOVER flag with a 'D'; Approved by: adrian Modified: head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Tue May 1 16:16:20 2012 (r234894) +++ head/sbin/ifconfig/ifieee80211.c Tue May 1 16:17:17 2012 (r234895) @@ -4020,6 +4020,8 @@ list_mesh(int s) ether_ntoa((const struct ether_addr *)rt->imr_nexthop), rt->imr_nhops, rt->imr_metric, rt->imr_lifetime, rt->imr_lastmseq, + (rt->imr_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) ? + 'D' : (rt->imr_flags & IEEE80211_MESHRT_FLAGS_VALID) ? 'V' : '!', (rt->imr_flags & IEEE80211_MESHRT_FLAGS_PROXY) ? From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:18:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A5D5106566C; Tue, 1 May 2012 16:18:39 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14C998FC08; Tue, 1 May 2012 16:18:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GIcMQ034504; Tue, 1 May 2012 16:18:38 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GIcsV034502; Tue, 1 May 2012 16:18:38 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205011618.q41GIcsV034502@svn.freebsd.org> From: Monthadar Al Jaberi Date: Tue, 1 May 2012 16:18:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234896 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:18:39 -0000 Author: monthadar Date: Tue May 1 16:18:38 2012 New Revision: 234896 URL: http://svn.freebsd.org/changeset/base/234896 Log: Update HWMP Proactive code and mesh route flags. * Modified hwmp_recv_preq: o cleaned up code, removed rootmac variable because preq->origaddr is the root when we recevie a Proactive PREQ; o Modified so that a PREP in response of a Proactive PREQ is unicast, a PREP is ALWAYS unicast; * Modified hwmp_recv_prep: o Before we mark a route to be valid we should remove the discovery flag and then mark it valid in such a way we wont lose the isgate flag; Approved by: adrian Modified: head/sys/net80211/ieee80211_hwmp.c Modified: head/sys/net80211/ieee80211_hwmp.c ============================================================================== --- head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:17:17 2012 (r234895) +++ head/sys/net80211/ieee80211_hwmp.c Tue May 1 16:18:38 2012 (r234896) @@ -904,7 +904,6 @@ hwmp_recv_preq(struct ieee80211vap *vap, const struct ieee80211_frame *wh, const struct ieee80211_meshpreq_ie *preq) { struct ieee80211_mesh_state *ms = vap->iv_mesh; - struct ieee80211_mesh_route *rt = NULL; /* pro-active code */ struct ieee80211_mesh_route *rtorig = NULL; struct ieee80211_mesh_route *rtorig_ext = NULL; struct ieee80211_mesh_route *rttarg = NULL; @@ -1083,33 +1082,20 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr) && (PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { - uint8_t rootmac[IEEE80211_ADDR_LEN]; - - IEEE80211_ADDR_COPY(rootmac, preq->preq_origaddr); - rt = ieee80211_mesh_rt_find(vap, rootmac); - if (rt == NULL) { - rt = ieee80211_mesh_rt_add(vap, rootmac); - if (rt == NULL) { - IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "unable to add root mesh path to %6D", - rootmac, ":"); - vap->iv_stats.is_mesh_rtaddfailed++; - return; - } - } IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, - "root mesh station @ %6D", rootmac, ":"); + "root mesh station @ %6D", preq->preq_origaddr, ":"); /* * Reply with a PREP if we don't have a path to the root * or if the root sent us a proactive PREQ. */ - if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 || + if ((rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0 || (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_PP)) { prep.prep_flags = 0; prep.prep_hopcount = 0; prep.prep_ttl = ms->ms_ttl; - IEEE80211_ADDR_COPY(prep.prep_origaddr, rootmac); + IEEE80211_ADDR_COPY(prep.prep_origaddr, + preq->preq_origaddr); prep.prep_origseq = preq->preq_origseq; prep.prep_lifetime = preq->preq_lifetime; prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL; @@ -1117,7 +1103,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, vap->iv_myaddr); prep.prep_targetseq = ++hs->hs_seq; hwmp_send_prep(vap->iv_bss, vap->iv_myaddr, - broadcastaddr, &prep); + rtorig->rt_nexthop, &prep); } } @@ -1319,7 +1305,11 @@ hwmp_recv_prep(struct ieee80211vap *vap, rt->rt_metric = metric; rt->rt_nhops = prep->prep_hopcount + 1; ieee80211_mesh_rt_update(rt, prep->prep_lifetime); - rt->rt_flags = IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ + if (rt->rt_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) { + /* discovery complete */ + rt->rt_flags &= ~IEEE80211_MESHRT_FLAGS_DISCOVER; + } + rt->rt_flags |= IEEE80211_MESHRT_FLAGS_VALID; /* mark valid */ /* * If it's NOT for us, propagate the PREP From owner-svn-src-head@FreeBSD.ORG Tue May 1 16:38:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F4841065670; Tue, 1 May 2012 16:38:34 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A1718FC15; Tue, 1 May 2012 16:38:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41GcYwb035297; Tue, 1 May 2012 16:38:34 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41GcYRW035295; Tue, 1 May 2012 16:38:34 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201205011638.q41GcYRW035295@svn.freebsd.org> From: Marius Strobl Date: Tue, 1 May 2012 16:38:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234897 - head/sys/boot/sparc64/loader X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 16:38:34 -0000 Author: marius Date: Tue May 1 16:38:33 2012 New Revision: 234897 URL: http://svn.freebsd.org/changeset/base/234897 Log: Add a command for showing the heap usage. PR: 165025 Submitted by: Gavin Mu MFC after: 1 week Modified: head/sys/boot/sparc64/loader/main.c Modified: head/sys/boot/sparc64/loader/main.c ============================================================================== --- head/sys/boot/sparc64/loader/main.c Tue May 1 16:18:38 2012 (r234896) +++ head/sys/boot/sparc64/loader/main.c Tue May 1 16:38:33 2012 (r234897) @@ -800,6 +800,18 @@ main(int (*openfirm)(void *)) return (1); } +COMMAND_SET(heap, "heap", "show heap usage", command_heap); + +static int +command_heap(int argc, char *argv[]) +{ + + mallocstats(); + printf("heap base at %p, top at %p, upper limit at %p\n", heapva, + sbrk(0), heapva + HEAPSZ); + return(CMD_OK); +} + COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); static int From owner-svn-src-head@FreeBSD.ORG Tue May 1 17:16:01 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CA9C21065672; Tue, 1 May 2012 17:16:01 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B26EF8FC0C; Tue, 1 May 2012 17:16:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41HG1BB036613; Tue, 1 May 2012 17:16:01 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41HG1fL036603; Tue, 1 May 2012 17:16:01 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201205011716.q41HG1fL036603@svn.freebsd.org> From: Marius Strobl Date: Tue, 1 May 2012 17:16:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234898 - in head/sys/boot: ofw/libofw sparc64 sparc64/boot1 sparc64/loader sparc64/zfsboot sparc64/zfsloader zfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 17:16:01 -0000 Author: marius Date: Tue May 1 17:16:01 2012 New Revision: 234898 URL: http://svn.freebsd.org/changeset/base/234898 Log: Add initial support for booting from ZFS on sparc64. At least on Sun Fire V100, the firmware is known to be broken and not allowing to simultaneously open disk devices, causing attempts to boot from a mirror or RAIDZ to cause a crash. This will be worked around later. The firmwares of newer sun4u models don't seem to exhibit this problem though. Steps for ZFS booting: 1. create VTOC8 label # gpart create -s vtoc8 da0 2. add partitions, f.e.: # gpart add -t freebsd-zfs -s 60g da0 # gpart add -t freebsd-swap da0 resulting in something like: # gpart show => 0 143331930 da0 VTOC8 (68G) 0 125821080 1 freebsd-zfs (60G) 125821080 17510850 2 freebsd-swap (8.4G) 3. create zpool # zpool create bunker da0a or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.): # zpool create bunker mirror da0a da1a # zpool create bunker raidz da0a da1a da2a ... 4. set bootfs # zpool set bootfs=bunker bunker 5. install zfsboot # zpool export bunker # gpart bootcode -p /boot/zfsboot da0 6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool for this, so dd(1) has to be used for this purpose) When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated for the additional disks in order to be able to boot from another disk in case of failure. # sysctl kern.geom.debugflags=0x10 # dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc # zpool import bunker 7. install system on ZFS filesystem Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in loader.conf as well as 'zfs_enable="YES"'in rc.conf. 8. copy zpool.cache to the ZFS filesystem cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache 9. set mountpoint # zfs set mountpoint=/ bunker 10. Now, given that aliases for all disks in the zpool exists (check with the `devalias` command on the boot monitor prompt) and disk0 corresponds to da0 (likewise for additional disks), the system can be booted from the ZFS with: {1} ok boot disk0 PR: 165025 Submitted by: Gavin Mu Added: head/sys/boot/sparc64/zfsboot/ head/sys/boot/sparc64/zfsboot/Makefile (contents, props changed) head/sys/boot/sparc64/zfsloader/ head/sys/boot/sparc64/zfsloader/Makefile (contents, props changed) Modified: head/sys/boot/ofw/libofw/devicename.c head/sys/boot/sparc64/Makefile head/sys/boot/sparc64/boot1/Makefile head/sys/boot/sparc64/boot1/boot1.c head/sys/boot/sparc64/loader/Makefile head/sys/boot/sparc64/loader/main.c head/sys/boot/zfs/zfs.c Modified: head/sys/boot/ofw/libofw/devicename.c ============================================================================== --- head/sys/boot/ofw/libofw/devicename.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/ofw/libofw/devicename.c Tue May 1 17:16:01 2012 (r234898) @@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$"); #include + +#include "bootstrap.h" #include "libofw.h" static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); @@ -76,6 +78,7 @@ ofw_parsedev(struct ofw_devdesc **dev, c phandle_t handle; const char *p; const char *s; + char *ep; char name[256]; char type[64]; int len; @@ -87,9 +90,10 @@ ofw_parsedev(struct ofw_devdesc **dev, c len = s - devspec; bcopy(devspec, name, len); name[len] = '\0'; - if ((handle = OF_finddevice(name)) == -1) - break; - if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1) + if ((handle = OF_finddevice(name)) == -1) { + bcopy(name, type, len); + type[len] = '\0'; + } else if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1) continue; for (i = 0; (dv = devsw[i]) != NULL; i++) { if (strncmp(dv->dv_name, type, strlen(dv->dv_name)) == 0) @@ -109,6 +113,18 @@ found: strcpy(idev->d_path, name); idev->d_dev = dv; idev->d_type = dv->dv_type; + if (idev->d_type == DEVT_ZFS) { + idev->d_unit = 0; + p = name + strlen(dv->dv_name); + if (*p && (*p != ':')) { + idev->d_unit = strtol(p, &ep, 0); + if (ep == p) { + free(idev); + return (EUNIT); + } + } + } + if (dev == NULL) { free(idev); } else { Modified: head/sys/boot/sparc64/Makefile ============================================================================== --- head/sys/boot/sparc64/Makefile Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= boot1 loader +SUBDIR= boot1 loader zfsboot zfsloader .include Modified: head/sys/boot/sparc64/boot1/Makefile ============================================================================== --- head/sys/boot/sparc64/boot1/Makefile Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/boot1/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -3,22 +3,23 @@ PROG= boot1.elf INTERNALPROG= NO_MAN= -FILES= boot1 +FILES?= boot1 SRCS= _start.s boot1.c +CLEANFILES+=boot1 boot1.aout BOOTBLOCKBASE= 0x4000 -CFLAGS= -mcmodel=medlow -Os -I${.CURDIR}/../../common +CFLAGS+=-mcmodel=medlow -Os -I${.CURDIR}/../../common LDFLAGS=-Ttext ${BOOTBLOCKBASE} -Wl,-N # Construct boot1. sunlabel expects it to contain zeroed-out space for the # label, and to be of the correct size. boot1: boot1.aout + @set -- `ls -l boot1.aout`; x=$$((7680-$$5)); \ + echo "$$x bytes available"; test $$x -ge 0 dd if=/dev/zero of=${.TARGET} bs=512 count=16 dd if=boot1.aout of=${.TARGET} bs=512 oseek=1 conv=notrunc -CLEANFILES= boot1.aout - boot1.aout: boot1.elf elf2aout -o ${.TARGET} ${.ALLSRC} Modified: head/sys/boot/sparc64/boot1/boot1.c ============================================================================== --- head/sys/boot/sparc64/boot1/boot1.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/boot1/boot1.c Tue May 1 17:16:01 2012 (r234898) @@ -20,11 +20,13 @@ __FBSDID("$FreeBSD$"); #include #include + #include #include -#define _PATH_LOADER "/boot/loader" -#define _PATH_KERNEL "/boot/kernel/kernel" +#define _PATH_LOADER "/boot/loader" +#define _PATH_KERNEL "/boot/kernel/kernel" +#define READ_BUF_SIZE 8192 typedef int putc_func_t(char c, void *arg); typedef int32_t ofwh_t; @@ -45,17 +47,21 @@ static ofwh_t bootdev; static uint32_t fs_off; int main(int ac, char **av); - static void exit(int) __dead2; -static void load(const char *); -static int dskread(void *, u_int64_t, int); - static void usage(void); +#ifdef ZFSBOOT +static void loadzfs(void); +static int zbread(char *buf, off_t off, size_t bytes); +#else +static void load(const char *); +#endif + static void bcopy(const void *src, void *dst, size_t len); static void bzero(void *b, size_t len); static int mount(const char *device); +static int dskread(void *buf, u_int64_t lba, int nblk); static void panic(const char *fmt, ...) __dead2; static int printf(const char *fmt, ...); @@ -312,8 +318,6 @@ strcmp(const char *s1, const char *s2) return ((u_char)*s1 - (u_char)*s2); } -#include "ufsread.c" - int main(int ac, char **av) { @@ -335,14 +339,22 @@ main(int ac, char **av) } } - printf(" \n>> FreeBSD/sparc64 boot block\n" - " Boot path: %s\n" - " Boot loader: %s\n", bootpath, path); +#ifdef ZFSBOOT + printf(" \n>> FreeBSD/sparc64 ZFS boot block\n Boot path: %s\n", + bootpath); +#else + printf(" \n>> FreeBSD/sparc64 boot block\n Boot path: %s\n" + " Boot loader: %s\n", "", bootpath, path); +#endif if (mount(bootpath) == -1) panic("mount"); +#ifdef ZFSBOOT + loadzfs(); +#else load(path); +#endif return (1); } @@ -361,24 +373,86 @@ exit(int code) ofw_exit(); } -static struct dmadat __dmadat; +#ifdef ZFSBOOT + +#define VDEV_BOOT_OFFSET (2 * 256 * 1024) +static char zbuf[READ_BUF_SIZE]; static int -mount(const char *device) +zbread(char *buf, off_t off, size_t bytes) { + size_t len; + off_t poff; + off_t soff; + char *p; + unsigned int nb; + unsigned int lb; - dmadat = &__dmadat; - if ((bootdev = ofw_open(device)) == -1) { - printf("mount: can't open device\n"); - return (-1); + p = buf; + soff = VDEV_BOOT_OFFSET + off; + lb = (soff + bytes + DEV_BSIZE - 1) / DEV_BSIZE; + poff = soff; + while (poff < soff + bytes) { + nb = lb - poff / DEV_BSIZE; + if (nb > READ_BUF_SIZE / DEV_BSIZE) + nb = READ_BUF_SIZE / DEV_BSIZE; + if (dskread(zbuf, poff / DEV_BSIZE, nb)) + break; + if ((poff / DEV_BSIZE + nb) * DEV_BSIZE > soff + bytes) + len = soff + bytes - poff; + else + len = (poff / DEV_BSIZE + nb) * DEV_BSIZE - poff; + memcpy(p, zbuf + poff % DEV_BSIZE, len); + p += len; + poff += len; } - if (fsread(0, NULL, 0)) { - printf("mount: can't read superblock\n"); - return (-1); + return (poff - soff); +} + +static void +loadzfs(void) +{ + Elf64_Ehdr eh; + Elf64_Phdr ph; + caddr_t p; + ino_t ino; + int i; + + if (zbread((char *)&eh, 0, sizeof(eh)) != sizeof(eh)) { + printf("Can't read elf header\n"); + return; } - return (0); + if (!IS_ELF(eh)) { + printf("Not an ELF file\n"); + return; + } + for (i = 0; i < eh.e_phnum; i++) { + fs_off = eh.e_phoff + i * eh.e_phentsize; + if (zbread((char *)&ph, fs_off, sizeof(ph)) != sizeof(ph)) { + printf("Can't read program header %d\n", i); + return; + } + if (ph.p_type != PT_LOAD) + continue; + fs_off = ph.p_offset; + p = (caddr_t)ph.p_vaddr; + if (zbread(p, fs_off, ph.p_filesz) != ph.p_filesz) { + printf("Can't read content of section %d\n", i); + return; + } + if (ph.p_filesz != ph.p_memsz) + bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); + } + ofw_close(bootdev); + (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); } +#else + +#include "ufsread.c" + +static struct dmadat __dmadat; + static void load(const char *fname) { @@ -421,6 +495,26 @@ load(const char *fname) (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); } +#endif /* ZFSBOOT */ + +static int +mount(const char *device) +{ + + if ((bootdev = ofw_open(device)) == -1) { + printf("mount: can't open device\n"); + return (-1); + } +#ifndef ZFSBOOT + dmadat = &__dmadat; + if (fsread(0, NULL, 0)) { + printf("mount: can't read superblock\n"); + return (-1); + } +#endif + return (0); +} + static int dskread(void *buf, u_int64_t lba, int nblk) { Modified: head/sys/boot/sparc64/loader/Makefile ============================================================================== --- head/sys/boot/sparc64/loader/Makefile Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/loader/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -3,8 +3,8 @@ .include MK_SSP= no -PROG= loader -NEWVERSWHAT= "bootstrap loader" sparc64 +PROG?= loader +NEWVERSWHAT?= "bootstrap loader" sparc64 INSTALLFLAGS= -b # Architecture-specific loader code @@ -13,12 +13,17 @@ SRCS= locore.S main.c metadata.c vers.c LOADER_DISK_SUPPORT?= yes LOADER_UFS_SUPPORT?= yes LOADER_CD9660_SUPPORT?= yes +LOADER_ZFS_SUPPORT?= no LOADER_NET_SUPPORT?= yes LOADER_NFS_SUPPORT?= yes LOADER_TFTP_SUPPORT?= yes LOADER_GZIP_SUPPORT?= yes LOADER_BZIP2_SUPPORT?= no +LOADER_DEBUG?= no +.if ${LOADER_DEBUG} == "yes" +CFLAGS+= -DLOADER_DEBUG +.endif .if ${LOADER_DISK_SUPPORT} == "yes" CFLAGS+= -DLOADER_DISK_SUPPORT .endif @@ -28,6 +33,11 @@ CFLAGS+= -DLOADER_UFS_SUPPORT .if ${LOADER_CD9660_SUPPORT} == "yes" CFLAGS+= -DLOADER_CD9660_SUPPORT .endif +.if ${LOADER_ZFS_SUPPORT} == "yes" +CFLAGS+= -DLOADER_ZFS_SUPPORT +CFLAGS+= -I${.CURDIR}/../../zfs +CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs +.endif .if ${LOADER_GZIP_SUPPORT} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT .endif @@ -47,7 +57,8 @@ CFLAGS+= -DLOADER_TFTP_SUPPORT .if ${MK_FORTH} != "no" # Enable BootForth BOOT_FORTH= yes -CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/sparc64 +CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl +CFLAGS+= -I${.CURDIR}/../../ficl/sparc64 LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .endif @@ -75,8 +86,9 @@ CFLAGS+= -I${.CURDIR}/../../../../lib/li DPADD= ${LIBFICL} ${LIBOFW} ${LIBSTAND} LDADD= ${LIBFICL} ${LIBOFW} -lstand -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version - sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version + sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../loader/version \ + ${NEWVERSWHAT} loader.help: help.common help.sparc64 cat ${.ALLSRC} | \ Modified: head/sys/boot/sparc64/loader/main.c ============================================================================== --- head/sys/boot/sparc64/loader/main.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/sparc64/loader/main.c Tue May 1 17:16:01 2012 (r234898) @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef LOADER_ZFS_SUPPORT +#include +#endif #include #include @@ -143,6 +146,11 @@ static vm_offset_t heapva; static phandle_t root; +#ifdef LOADER_ZFS_SUPPORT +static int zfs_dev_init(void); +#include "zfs.c" +#endif + /* * Machine dependent structures that the machine independent * loader part uses. @@ -154,6 +162,9 @@ struct devsw *devsw[] = { #ifdef LOADER_NET_SUPPORT &netdev, #endif +#ifdef LOADER_ZFS_SUPPORT + &zfs_dev, +#endif 0 }; struct arch_switch archsw; @@ -166,6 +177,7 @@ struct file_format *file_formats[] = { &sparc64_elf, 0 }; + struct fs_ops *file_system[] = { #ifdef LOADER_UFS_SUPPORT &ufs_fsops, @@ -173,6 +185,9 @@ struct fs_ops *file_system[] = { #ifdef LOADER_CD9660_SUPPORT &cd9660_fsops, #endif +#ifdef LOADER_ZFS_SUPPORT + &zfs_fsops, +#endif #ifdef LOADER_ZIP_SUPPORT &zipfs_fsops, #endif @@ -721,6 +736,82 @@ tlb_init_sun4u(void) panic("%s: can't allocate TLB store", __func__); } +#ifdef LOADER_ZFS_SUPPORT + +static int +zfs_dev_init(void) +{ + struct vtoc8 vtoc; + char devname[512]; + spa_t *spa; + vdev_t *vdev; + uint64_t guid; + int fd, part, unit; + + zfs_init(); + + guid = 0; + /* Get the GUID of the ZFS pool on the boot device. */ + fd = open(getenv("currdev"), O_RDONLY); + if (fd != -1) { + if (vdev_probe(vdev_read, (void *)(uintptr_t) fd, &spa) == 0) + guid = spa->spa_guid; + close(fd); + } + + /* Clean up the environment to let ZFS work. */ + while ((vdev = STAILQ_FIRST(&zfs_vdevs)) != NULL) { + STAILQ_REMOVE_HEAD(&zfs_vdevs, v_alllink); + free(vdev); + } + while ((spa = STAILQ_FIRST(&zfs_pools)) != NULL) { + STAILQ_REMOVE_HEAD(&zfs_pools, spa_link); + free(spa); + } + + for (unit = 0; unit < MAXBDDEV; unit++) { + /* Find freebsd-zfs slices in the VTOC. */ + sprintf(devname, "disk%d:", unit); + fd = open(devname, O_RDONLY); + if (fd == -1) + continue; + lseek(fd, 0, SEEK_SET); + if (read(fd, &vtoc, sizeof(vtoc)) != sizeof(vtoc)) { + close(fd); + continue; + } + close(fd); + + for (part = 0; part < 8; part++) { + if (part == 2 || vtoc.part[part].tag != + VTOC_TAG_FREEBSD_ZFS) + continue; + sprintf(devname, "disk%d:%c", unit, part + 'a'); + fd = open(devname, O_RDONLY); + if (fd == -1) + break; + + if (vdev_probe(vdev_read, (void*)(uintptr_t) fd, 0)) + close(fd); + } + } + + if (guid != 0) { + unit = zfs_guid_to_unit(guid); + if (unit >= 0) { + /* Update the environment for ZFS. */ + sprintf(devname, "zfs%d", unit); + env_setenv("currdev", EV_VOLATILE, devname, + ofw_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, devname, + env_noset, env_nounset); + } + } + return (0); +} + +#endif /* LOADER_ZFS_SUPPORT */ + int main(int (*openfirm)(void *)) { @@ -756,14 +847,6 @@ main(int (*openfirm)(void *)) mmu_ops->tlb_init(); /* - * Initialize devices. - */ - for (dp = devsw; *dp != 0; dp++) { - if ((*dp)->dv_init != 0) - (*dp)->dv_init(); - } - - /* * Set up the current device. */ OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath)); @@ -780,7 +863,8 @@ main(int (*openfirm)(void *)) * needs to be altered. */ if (bootpath[strlen(bootpath) - 2] == ':' && - bootpath[strlen(bootpath) - 1] == 'f') { + bootpath[strlen(bootpath) - 1] == 'f' && + strstr(bootpath, "cdrom")) { bootpath[strlen(bootpath) - 1] = 'a'; printf("Boot path set to %s\n", bootpath); } @@ -790,6 +874,13 @@ main(int (*openfirm)(void *)) env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset, env_nounset); + /* + * Initialize devices. + */ + for (dp = devsw; *dp != 0; dp++) + if ((*dp)->dv_init != 0) + (*dp)->dv_init(); + printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); Added: head/sys/boot/sparc64/zfsboot/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/sparc64/zfsboot/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../boot1 + +PROGNAME= zfsboot +CFLAGS+= -DZFSBOOT +FILES= zfsboot +CLEANFILES+= zfsboot + +zfsboot: boot1 + ln -s ${.ALLSRC} ${.TARGET} + +.include "${.CURDIR}/../boot1/Makefile" Added: head/sys/boot/sparc64/zfsloader/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/sparc64/zfsloader/Makefile Tue May 1 17:16:01 2012 (r234898) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../loader + +PROG= zfsloader +NEWVERSWHAT= "ZFS enabled bootstrap loader" sparc64 +LOADER_ZFS_SUPPORT=yes + +.include "${.CURDIR}/../loader/Makefile" Modified: head/sys/boot/zfs/zfs.c ============================================================================== --- head/sys/boot/zfs/zfs.c Tue May 1 16:38:33 2012 (r234897) +++ head/sys/boot/zfs/zfs.c Tue May 1 17:16:01 2012 (r234898) @@ -399,6 +399,7 @@ zfs_guid_to_unit(uint64_t guid) return (-1); } +#if defined(__amd64__) || defined(__i386__) static int zfs_dev_init(void) { @@ -441,6 +442,7 @@ zfs_dev_init(void) return (0); } +#endif /* * Print information about ZFS pools From owner-svn-src-head@FreeBSD.ORG Tue May 1 18:00:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13ECC106567B; Tue, 1 May 2012 18:00:32 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA0268FC0A; Tue, 1 May 2012 18:00:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41I0VAc038187; Tue, 1 May 2012 18:00:31 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41I0VKA038185; Tue, 1 May 2012 18:00:31 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205011800.q41I0VKA038185@svn.freebsd.org> From: Alexander Motin Date: Tue, 1 May 2012 18:00:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234899 - head/sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 18:00:32 -0000 Author: mav Date: Tue May 1 18:00:31 2012 New Revision: 234899 URL: http://svn.freebsd.org/changeset/base/234899 Log: Improve spare disks support. Unluckily, for some reason Adaptec 1430SA RAID BIOS doesn't want to understand spare disks created by graid. But at least spares created by BIOS are working fine now. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Tue May 1 17:16:01 2012 (r234898) +++ head/sys/geom/raid/md_ddf.c Tue May 1 18:00:31 2012 (r234899) @@ -179,6 +179,10 @@ static struct g_raid_md_class g_raid_md_ (n) * GET16((m), hdr->Configuration_Record_Length) * \ (m)->sectorsize)) +#define GETSAPTR(m, n) ((struct ddf_sa_record *)((uint8_t *)(m)->cr + \ + (n) * GET16((m), hdr->Configuration_Record_Length) * \ + (m)->sectorsize)) + static int isff(uint8_t *buf, int size) { @@ -294,8 +298,8 @@ g_raid_md_ddf_print(struct ddf_meta *met printf("\n"); printf("VD_Number 0x%04x\n", GET16(meta, vdr->entry[j].VD_Number)); - printf("VD_Type 0x%02x\n", - GET8(meta, vdr->entry[j].VD_Type)); + printf("VD_Type 0x%04x\n", + GET16(meta, vdr->entry[j].VD_Type)); printf("VD_State 0x%02x\n", GET8(meta, vdr->entry[j].VD_State)); printf("Init_State 0x%02x\n", @@ -396,6 +400,7 @@ g_raid_md_ddf_print(struct ddf_meta *met GET16D(meta, sa->entry[i].Secondary_Element)); } break; + case 0x00000000: case 0xFFFFFFFF: break; default: @@ -476,7 +481,8 @@ ddf_meta_find_vdc(struct ddf_meta *meta, memcmp(vdc->VD_GUID, GUID, 24) == 0) return (vdc); } else - if (GET32D(meta, vdc->Signature) == 0xffffffff) + if (GET32D(meta, vdc->Signature) == 0xffffffff || + GET32D(meta, vdc->Signature) == 0) return (vdc); } return (NULL); @@ -527,6 +533,29 @@ ddf_meta_find_disk(struct ddf_vol_meta * return (-1); } +static struct ddf_sa_record * +ddf_meta_find_sa(struct ddf_meta *meta, int create) +{ + struct ddf_sa_record *sa; + int i, num; + + num = GETCRNUM(meta); + for (i = 0; i < num; i++) { + sa = GETSAPTR(meta, i); + if (GET32D(meta, sa->Signature) == DDF_SA_SIGNATURE) + return (sa); + } + if (create) { + for (i = 0; i < num; i++) { + sa = GETSAPTR(meta, i); + if (GET32D(meta, sa->Signature) == 0xffffffff || + GET32D(meta, sa->Signature) == 0) + return (sa); + } + } + return (NULL); +} + static void ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample) { @@ -643,9 +672,9 @@ ddf_meta_create(struct g_raid_disk *disk pos += GET32(meta, hdr->Diagnostic_Space_Length); SET32(meta, hdr->Vendor_Specific_Logs, GET32(meta, hdr->Vendor_Specific_Logs_Length) != 0 ? pos : 0xffffffff); - pos += GET32(meta, hdr->Vendor_Specific_Logs_Length); + pos += min(GET32(meta, hdr->Vendor_Specific_Logs_Length), 1); SET64(meta, hdr->Primary_Header_LBA, - anchorlba - pos - 16); + anchorlba - pos); SET64(meta, hdr->Secondary_Header_LBA, 0xffffffffffffffffULL); SET64(meta, hdr->WorkSpace_LBA, @@ -1318,29 +1347,6 @@ ddf_meta_erase(struct g_consumer *cp) return (error); } -#if 0 -static int -ddf_meta_write_spare(struct g_consumer *cp) -{ - struct ddf_header *meta; - int error; - - meta = malloc(sizeof(*meta), M_MD_DDF, M_WAITOK | M_ZERO); - memcpy(&meta->ddf_id[0], DDF_MAGIC, sizeof(DDF_MAGIC) - 1); - meta->dummy_0 = 0x00020000; - meta->integrity = DDF_I_VALID; - meta->disk.flags = DDF_F_SPARE | DDF_F_ONLINE | DDF_F_VALID; - meta->disk.number = 0xff; - arc4rand(&meta->disk.id, sizeof(meta->disk.id), 0); - meta->disk_sectors = cp->provider->mediasize / cp->provider->sectorsize; - meta->disk_sectors -= 131072; - meta->rebuild_lba = UINT32_MAX; - error = ddf_meta_write(cp, &meta, 1); - free(meta, M_MD_DDF); - return (error); -} -#endif - static struct g_raid_volume * g_raid_md_ddf_get_volume(struct g_raid_softc *sc, uint8_t *GUID) { @@ -1574,6 +1580,7 @@ g_raid_md_ddf_start_disk(struct g_raid_d struct ddf_vol_meta *vmeta; struct ddf_meta *pdmeta, *gmeta; struct ddf_vdc_record *vdc1; + struct ddf_sa_record *sa; off_t size, eoff = 0, esize = 0; uint64_t *val2; int disk_pos, md_disk_bvd = -1, md_disk_pos = -1, md_pde_pos; @@ -1596,7 +1603,8 @@ g_raid_md_ddf_start_disk(struct g_raid_d md_pde_pos = ddf_meta_find_pd(gmeta, NULL, reference); if (disk_pos < 0) { - G_RAID_DEBUG1(1, sc, "Disk %s is not part of the volume %s", + G_RAID_DEBUG1(1, sc, + "Disk %s is not a present part of the volume %s", g_raid_get_diskname(disk), vol->v_name); /* Failed stale disk is useless for us. */ @@ -1606,10 +1614,8 @@ g_raid_md_ddf_start_disk(struct g_raid_d } /* If disk has some metadata for this volume - erase. */ - if (pdmeta->cr != NULL && - (vdc1 = ddf_meta_find_vdc(pdmeta, vmeta->vdc->VD_GUID)) != NULL) { + if ((vdc1 = ddf_meta_find_vdc(pdmeta, vmeta->vdc->VD_GUID)) != NULL) SET32D(pdmeta, vdc1->Signature, 0xffffffff); - } /* If we are in the start process, that's all for now. */ if (!pv->pv_started) @@ -1656,12 +1662,28 @@ g_raid_md_ddf_start_disk(struct g_raid_d md_disk_pos = disk_pos % GET16(vmeta, vdc->Primary_Element_Count); // XXX } else { nofit: - if (ddf_meta_count_vdc(&pd->pd_meta, NULL) == 0) { + if (disk->d_state == G_RAID_DISK_S_NONE) g_raid_change_disk_state(disk, - G_RAID_DISK_S_SPARE); - } + G_RAID_DISK_S_STALE); return (0); } + + /* + * If spare is committable, delete spare record. + * Othersize, mark it active and leave there. + */ + sa = ddf_meta_find_sa(&pd->pd_meta, 0); + if (sa != NULL) { + if ((GET8D(&pd->pd_meta, sa->Spare_Type) & + DDF_SAR_TYPE_REVERTIBLE) == 0) { + SET32D(&pd->pd_meta, sa->Signature, 0xffffffff); + } else { + SET8D(&pd->pd_meta, sa->Spare_Type, + GET8D(&pd->pd_meta, sa->Spare_Type) | + DDF_SAR_TYPE_ACTIVE); + } + } + G_RAID_DEBUG1(1, sc, "Disk %s takes pos %d in the volume %s", g_raid_get_diskname(disk), disk_pos, vol->v_name); resurrection = 1; @@ -1798,6 +1820,7 @@ g_raid_md_ddf_start(struct g_raid_volume struct g_raid_subdisk *sd; struct g_raid_disk *disk; struct g_raid_md_object *md; + struct g_raid_md_ddf_perdisk *pd; struct g_raid_md_ddf_pervolume *pv; struct g_raid_md_ddf_object *mdi; struct ddf_vol_meta *vmeta; @@ -1846,16 +1869,9 @@ g_raid_md_ddf_start(struct g_raid_volume g_raid_start_volume(vol); /* Make all disks found till the moment take their places. */ - for (i = 0, j = 0, bvd = 0; i < vol->v_disks_count; i++, j++) { - if (j == GET16(vmeta, vdc->Primary_Element_Count)) { - j = 0; - bvd++; - } - if (vmeta->bvdc[bvd] == NULL) - continue; - disk = g_raid_md_ddf_get_disk(sc, NULL, - GET32(vmeta, bvdc[bvd]->Physical_Disk_Sequence[j])); - if (disk != NULL) + TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + if (ddf_meta_find_vdc(&pd->pd_meta, vmeta->vdc->VD_GUID) != NULL) g_raid_md_ddf_start_disk(disk, vol); } @@ -1901,7 +1917,7 @@ g_raid_md_ddf_new_disk(struct g_raid_dis struct ddf_vol_meta *vmeta; struct ddf_vdc_record *vdc; struct ddf_vd_entry *vde; - int i, j, k, num, have, need, needthis, cnt, spare; + int i, j, k, num, have, need, cnt, spare; uint32_t val; char buf[17]; @@ -1963,9 +1979,17 @@ g_raid_md_ddf_new_disk(struct g_raid_dis pv = vol->v_md_data; vmeta = &pv->pv_meta; + if (ddf_meta_find_vdc(pdmeta, vmeta->vdc->VD_GUID) == NULL) + continue; + + if (pv->pv_started) { + if (g_raid_md_ddf_start_disk(disk, vol)) + g_raid_md_write_ddf(md, vol, NULL, NULL); + continue; + } + /* If we collected all needed disks - start array. */ need = 0; - needthis = 0; have = 0; for (k = 0; k < GET8(vmeta, vdc->Secondary_Element_Count); k++) { if (vmeta->bvdc[k] == NULL) { @@ -1976,23 +2000,14 @@ g_raid_md_ddf_new_disk(struct g_raid_dis need += cnt; for (i = 0; i < cnt; i++) { val = GET32(vmeta, bvdc[k]->Physical_Disk_Sequence[i]); - if (GET32(pdmeta, pdd->PD_Reference) == val) - needthis++; - else if (g_raid_md_ddf_get_disk(sc, NULL, val) != NULL) + if (g_raid_md_ddf_get_disk(sc, NULL, val) != NULL) have++; } } - if (!needthis) - continue; - if (pv->pv_started) { - if (g_raid_md_ddf_start_disk(disk, vol)) - g_raid_md_write_ddf(md, vol, NULL, NULL); - } else { - G_RAID_DEBUG1(1, sc, "Volume %s now has %d of %d disks", - vol->v_name, have + needthis, need); - if (have + needthis == need) - g_raid_md_ddf_start(vol); - } + G_RAID_DEBUG1(1, sc, "Volume %s now has %d of %d disks", + vol->v_name, have, need); + if (have == need) + g_raid_md_ddf_start(vol); } } @@ -2173,6 +2188,7 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec struct g_raid_md_ddf_perdisk *pd; struct g_raid_md_ddf_pervolume *pv; struct g_raid_md_ddf_object *mdi; + struct ddf_sa_record *sa; struct g_consumer *cp; struct g_provider *pp; char arg[16]; @@ -2610,11 +2626,23 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec /* Welcome the "new" disk. */ g_raid_change_disk_state(disk, G_RAID_DISK_S_SPARE); ddf_meta_create(disk, &mdi->mdio_meta); + sa = ddf_meta_find_sa(&pd->pd_meta, 1); + if (sa != NULL) { + SET32D(&pd->pd_meta, sa->Signature, + DDF_SA_SIGNATURE); + SET8D(&pd->pd_meta, sa->Spare_Type, 0); + SET16D(&pd->pd_meta, sa->Populated_SAEs, 0); + SET16D(&pd->pd_meta, sa->MAX_SAE_Supported, + (GET16(&pd->pd_meta, hdr->Configuration_Record_Length) * + pd->pd_meta.sectorsize - + sizeof(struct ddf_sa_record)) / + sizeof(struct ddf_sa_entry)); + } if (mdi->mdio_meta.hdr == NULL) ddf_meta_copy(&mdi->mdio_meta, &pd->pd_meta); else ddf_meta_update(&mdi->mdio_meta, &pd->pd_meta); -// ddf_meta_write_spare(cp); + g_raid_md_write_ddf(md, NULL, NULL, NULL); g_raid_md_ddf_refill(sc); } return (error); @@ -2636,6 +2664,7 @@ g_raid_md_write_ddf(struct g_raid_md_obj struct ddf_meta *gmeta; struct ddf_vol_meta *vmeta; struct ddf_vdc_record *vdc; + struct ddf_sa_record *sa; uint64_t *val2; int i, j, pos, bvd, size; @@ -2657,7 +2686,8 @@ g_raid_md_write_ddf(struct g_raid_md_obj continue; SET16(gmeta, pdr->entry[i].PD_Type, GET16(gmeta, pdr->entry[i].PD_Type) & - ~DDF_PDE_PARTICIPATING); + ~(DDF_PDE_PARTICIPATING | + DDF_PDE_GLOBAL_SPARE | DDF_PDE_CONFIG_SPARE)); if ((GET16(gmeta, pdr->entry[i].PD_State) & DDF_PDE_PFA) == 0) SET16(gmeta, pdr->entry[i].PD_State, 0); @@ -2759,15 +2789,15 @@ g_raid_md_write_ddf(struct g_raid_md_obj if (sd->sd_state == G_RAID_SUBDISK_S_NONE) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED | DDF_PDE_MISSING); + (DDF_PDE_FAILED | DDF_PDE_MISSING)); else if (sd->sd_state == G_RAID_SUBDISK_S_FAILED) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED | DDF_PDE_PFA); + (DDF_PDE_FAILED | DDF_PDE_PFA)); else if (sd->sd_state <= G_RAID_SUBDISK_S_REBUILD) SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | - DDF_PDE_FAILED); + DDF_PDE_REBUILD); else SET32(gmeta, pdr->entry[j].PD_State, GET32(gmeta, pdr->entry[j].PD_State) | @@ -2775,11 +2805,46 @@ g_raid_md_write_ddf(struct g_raid_md_obj } } + /* Mark spare and failed disks as such. */ + TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { + pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; + i = ddf_meta_find_pd(gmeta, NULL, + GET32(&pd->pd_meta, pdd->PD_Reference)); + if (i < 0) + continue; + if (disk->d_state == G_RAID_DISK_S_FAILED) { + SET32(gmeta, pdr->entry[i].PD_State, + GET32(gmeta, pdr->entry[i].PD_State) | + (DDF_PDE_FAILED | DDF_PDE_PFA)); + } + if (disk->d_state != G_RAID_DISK_S_SPARE) + continue; + sa = ddf_meta_find_sa(&pd->pd_meta, 0); + if (sa == NULL || + (GET8D(&pd->pd_meta, sa->Spare_Type) & + DDF_SAR_TYPE_DEDICATED) == 0) { + SET16(gmeta, pdr->entry[i].PD_Type, + GET16(gmeta, pdr->entry[i].PD_Type) | + DDF_PDE_GLOBAL_SPARE); + } else { + SET16(gmeta, pdr->entry[i].PD_Type, + GET16(gmeta, pdr->entry[i].PD_Type) | + DDF_PDE_CONFIG_SPARE); + } + SET32(gmeta, pdr->entry[i].PD_State, + GET32(gmeta, pdr->entry[i].PD_State) | + DDF_PDE_ONLINE); + } + /* Remove disks without "participating" flag (unused). */ for (i = 0, j = -1; i < GET16(gmeta, pdr->Populated_PDEs); i++) { if (isff(gmeta->pdr->entry[i].PD_GUID, 24)) continue; - if (GET16(gmeta, pdr->entry[i].PD_Type) & DDF_PDE_PARTICIPATING) + if ((GET16(gmeta, pdr->entry[i].PD_Type) & + (DDF_PDE_PARTICIPATING | + DDF_PDE_GLOBAL_SPARE | DDF_PDE_CONFIG_SPARE)) != 0 || + g_raid_md_ddf_get_disk(sc, + NULL, GET32(gmeta, pdr->entry[i].PD_Reference)) != NULL) j = i; else memset(&gmeta->pdr->entry[i], 0xff, @@ -2790,7 +2855,8 @@ g_raid_md_write_ddf(struct g_raid_md_obj /* Update per-disk metadata and write them. */ TAILQ_FOREACH(disk, &sc->sc_disks, d_next) { pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; - if (disk->d_state != G_RAID_DISK_S_ACTIVE) + if (disk->d_state != G_RAID_DISK_S_ACTIVE && + disk->d_state != G_RAID_DISK_S_SPARE) continue; /* Update PDR. */ memcpy(pd->pd_meta.pdr, gmeta->pdr, From owner-svn-src-head@FreeBSD.ORG Tue May 1 20:32:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 03806106564A; Tue, 1 May 2012 20:32:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E2C298FC0A; Tue, 1 May 2012 20:32:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41KWcVl043421; Tue, 1 May 2012 20:32:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41KWcax043419; Tue, 1 May 2012 20:32:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205012032.q41KWcax043419@svn.freebsd.org> From: Adrian Chadd Date: Tue, 1 May 2012 20:32:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234900 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 20:32:39 -0000 Author: adrian Date: Tue May 1 20:32:38 2012 New Revision: 234900 URL: http://svn.freebsd.org/changeset/base/234900 Log: Add in the MII configuration parameters for the AR71xx. Obtained from: Linux/OpenWRT Modified: head/sys/mips/atheros/ar71xxreg.h Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Tue May 1 18:00:31 2012 (r234899) +++ head/sys/mips/atheros/ar71xxreg.h Tue May 1 20:32:38 2012 (r234900) @@ -271,12 +271,23 @@ * AR71xx MII control region */ #define AR71XX_MII0_CTRL 0x18070000 -#define AR71XX_MII1_CTRL 0x18070004 #define MII_CTRL_SPEED_SHIFT 4 #define MII_CTRL_SPEED_MASK 3 -#define MII_CTRL_SPEED_10 0 -#define MII_CTRL_SPEED_100 1 -#define MII_CTRL_SPEED_1000 2 +#define MII_CTRL_SPEED_10 0 +#define MII_CTRL_SPEED_100 1 +#define MII_CTRL_SPEED_1000 2 +#define MII_CTRL_IF_MASK 3 +#define MII_CTRL_IF_SHIFT 0 +#define MII0_CTRL_IF_GMII 0 +#define MII0_CTRL_IF_MII 1 +#define MII0_CTRL_IF_RGMII 2 +#define MII0_CTRL_IF_RMII 3 + +#define AR71XX_MII1_CTRL 0x18070004 + +#define MII1_CTRL_IF_RGMII 0 +#define MII1_CTRL_IF_RMII 1 + /* * GigE adapters region From owner-svn-src-head@FreeBSD.ORG Tue May 1 20:42:04 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4C6A91065670; Tue, 1 May 2012 20:42:04 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34D348FC16; Tue, 1 May 2012 20:42:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q41Kg4DU043807; Tue, 1 May 2012 20:42:04 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q41Kg4Jj043805; Tue, 1 May 2012 20:42:04 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201205012042.q41Kg4Jj043805@svn.freebsd.org> From: Marius Strobl Date: Tue, 1 May 2012 20:42:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234901 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 20:42:04 -0000 Author: marius Date: Tue May 1 20:42:03 2012 New Revision: 234901 URL: http://svn.freebsd.org/changeset/base/234901 Log: - Add missing locking in at91_usart_getc(). - Align the RX buffers on the cache line size, otherwise the requirement of partial cache line flushes on every are pretty much guaranteed. [1] - Make the code setting the RX timeout match its comment (apparently, start and stop bits were missed in the previous calculation). [1] - Cover the busdma operations in at91_usart_bus_{ipend,transmit}() with the hardware mutex, too, so these don't race against each other. - In at91_usart_bus_ipend(), reduce duplication in the code dealing with TX interrupts. - In at91_usart_bus_ipend(), turn the code dealing with RX interrupts into an else-if cascade in order reduce its complexity and to improve its run-time behavior. - In at91_usart_bus_ipend(), add missing BUS_DMASYNC_PREREAD calls on the RX buffer map before handing things over to the hardware again. [1] - In at91_usart_bus_getsig(), used a variable of sufficient width for storing the contents of USART_CSR. - Use KOBJMETHOD_END. - Remove an unused header. Submitted by: Ian Lepore [1] Reviewed by: Ian Lepore MFC after: 1 week Modified: head/sys/arm/at91/uart_dev_at91usart.c Modified: head/sys/arm/at91/uart_dev_at91usart.c ============================================================================== --- head/sys/arm/at91/uart_dev_at91usart.c Tue May 1 20:32:38 2012 (r234900) +++ head/sys/arm/at91/uart_dev_at91usart.c Tue May 1 20:42:03 2012 (r234901) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -55,16 +54,17 @@ __FBSDID("$FreeBSD$"); */ struct at91_usart_rx { bus_addr_t pa; - uint8_t buffer[USART_BUFFER_SIZE]; + uint8_t *buffer; bus_dmamap_t map; }; struct at91_usart_softc { struct uart_softc base; - bus_dma_tag_t dmatag; /* bus dma tag for mbufs */ + bus_dma_tag_t tx_tag; bus_dmamap_t tx_map; uint32_t flags; -#define HAS_TIMEOUT 1 +#define HAS_TIMEOUT 1 + bus_dma_tag_t rx_tag; struct at91_usart_rx ping_pong[2]; struct at91_usart_rx *ping; struct at91_usart_rx *pong; @@ -95,7 +95,7 @@ static void at91_usart_init(struct uart_ static void at91_usart_term(struct uart_bas *bas); static void at91_usart_putc(struct uart_bas *bas, int); static int at91_usart_rxready(struct uart_bas *bas); -static int at91_usart_getc(struct uart_bas *bas, struct mtx *mtx); +static int at91_usart_getc(struct uart_bas *bas, struct mtx *hwmtx); extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; @@ -106,7 +106,7 @@ at91_usart_param(struct uart_bas *bas, i uint32_t mr; /* - * Assume 3-write RS-232 configuration. + * Assume 3-wire RS-232 configuration. * XXX Not sure how uart will present the other modes to us, so * XXX they are unimplemented. maybe ioctl? */ @@ -209,6 +209,7 @@ static struct uart_ops at91_usart_ops = static int at91_usart_probe(struct uart_bas *bas) { + /* We know that this is always here */ return (0); } @@ -236,6 +237,7 @@ at91_usart_init(struct uart_bas *bas, in static void at91_usart_term(struct uart_bas *bas) { + /* XXX */ } @@ -247,7 +249,7 @@ static void at91_usart_putc(struct uart_bas *bas, int c) { - while (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) + while (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) continue; WR4(bas, USART_THR, c); } @@ -266,14 +268,18 @@ at91_usart_rxready(struct uart_bas *bas) * Block waiting for a character. */ static int -at91_usart_getc(struct uart_bas *bas, struct mtx *mtx) +at91_usart_getc(struct uart_bas *bas, struct mtx *hwmtx) { int c; - while (!(RD4(bas, USART_CSR) & USART_CSR_RXRDY)) - continue; - c = RD4(bas, USART_RHR); - c &= 0xff; + uart_lock(hwmtx); + while (!(RD4(bas, USART_CSR) & USART_CSR_RXRDY)) { + uart_unlock(hwmtx); + DELAY(4); + uart_lock(hwmtx); + } + c = RD4(bas, USART_RHR) & 0xff; + uart_unlock(hwmtx); return (c); } @@ -290,7 +296,7 @@ static int at91_usart_bus_transmit(struc static kobj_method_t at91_usart_methods[] = { KOBJMETHOD(uart_probe, at91_usart_bus_probe), - KOBJMETHOD(uart_attach, at91_usart_bus_attach), + KOBJMETHOD(uart_attach, at91_usart_bus_attach), KOBJMETHOD(uart_flush, at91_usart_bus_flush), KOBJMETHOD(uart_getsig, at91_usart_bus_getsig), KOBJMETHOD(uart_ioctl, at91_usart_bus_ioctl), @@ -299,8 +305,8 @@ static kobj_method_t at91_usart_methods[ KOBJMETHOD(uart_receive, at91_usart_bus_receive), KOBJMETHOD(uart_setsig, at91_usart_bus_setsig), KOBJMETHOD(uart_transmit, at91_usart_bus_transmit), - - { 0, 0 } + + KOBJMETHOD_END }; int @@ -316,6 +322,7 @@ at91_usart_bus_probe(struct uart_softc * static void at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) { + if (error != 0) return; *(bus_addr_t *)arg = segs[0].ds_addr; @@ -344,41 +351,53 @@ at91_usart_bus_attach(struct uart_softc WR4(&sc->sc_bas, USART_IDR, 0xffffffff); /* - * Allocate DMA tags and maps + * Allocate transmit DMA tag and map. We allow a transmit buffer + * to be any size, but it must map to a single contiguous physical + * extent. */ err = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - USART_BUFFER_SIZE, 1, USART_BUFFER_SIZE, BUS_DMA_ALLOCNOW, NULL, - NULL, &atsc->dmatag); + BUS_SPACE_MAXSIZE_32BIT, 1, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, + NULL, &atsc->tx_tag); if (err != 0) goto errout; - err = bus_dmamap_create(atsc->dmatag, 0, &atsc->tx_map); + err = bus_dmamap_create(atsc->tx_tag, 0, &atsc->tx_map); if (err != 0) goto errout; + if (atsc->flags & HAS_TIMEOUT) { + /* + * Allocate receive DMA tags, maps, and buffers. + * The receive buffers should be aligned to arm_dcache_align, + * otherwise partial cache line flushes on every receive + * interrupt are pretty much guaranteed. + */ + err = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), + arm_dcache_align, 0, BUS_SPACE_MAXADDR_32BIT, + BUS_SPACE_MAXADDR, NULL, NULL, sc->sc_rxfifosz, 1, + sc->sc_rxfifosz, BUS_DMA_ALLOCNOW, NULL, NULL, + &atsc->rx_tag); + if (err != 0) + goto errout; for (i = 0; i < 2; i++) { - err = bus_dmamap_create(atsc->dmatag, 0, - &atsc->ping_pong[i].map); + err = bus_dmamem_alloc(atsc->rx_tag, + (void **)&atsc->ping_pong[i].buffer, + BUS_DMA_NOWAIT, &atsc->ping_pong[i].map); if (err != 0) goto errout; - err = bus_dmamap_load(atsc->dmatag, + err = bus_dmamap_load(atsc->rx_tag, atsc->ping_pong[i].map, atsc->ping_pong[i].buffer, sc->sc_rxfifosz, at91_getaddr, &atsc->ping_pong[i].pa, 0); if (err != 0) goto errout; - bus_dmamap_sync(atsc->dmatag, atsc->ping_pong[i].map, + bus_dmamap_sync(atsc->rx_tag, atsc->ping_pong[i].map, BUS_DMASYNC_PREREAD); } atsc->ping = &atsc->ping_pong[0]; atsc->pong = &atsc->ping_pong[1]; } - /* - * Prime the pump with the RX buffer. We use two 64 byte bounce - * buffers here to avoid data overflow. - */ - /* Turn on rx and tx */ cr = USART_CR_RSTSTA | USART_CR_RSTRX | USART_CR_RSTTX; WR4(&sc->sc_bas, USART_CR, cr); @@ -397,8 +416,11 @@ at91_usart_bus_attach(struct uart_softc WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); - /* Set the receive timeout to be 1.5 character times. */ - WR4(&sc->sc_bas, USART_RTOR, 12); + /* + * Set the receive timeout to be 1.5 character times + * assuming 8N1. + */ + WR4(&sc->sc_bas, USART_RTOR, 15); WR4(&sc->sc_bas, USART_CR, USART_CR_STTTO); WR4(&sc->sc_bas, USART_IER, USART_CSR_TIMEOUT | USART_CSR_RXBUFF | USART_CSR_ENDRX); @@ -407,7 +429,6 @@ at91_usart_bus_attach(struct uart_softc } WR4(&sc->sc_bas, USART_IER, USART_CSR_RXBRK); errout: - // XXX bad return (err); } @@ -416,14 +437,17 @@ at91_usart_bus_transmit(struct uart_soft { bus_addr_t addr; struct at91_usart_softc *atsc; + int err; + err = 0; atsc = (struct at91_usart_softc *)sc; - if (bus_dmamap_load(atsc->dmatag, atsc->tx_map, sc->sc_txbuf, - sc->sc_txdatasz, at91_getaddr, &addr, 0) != 0) - return (EAGAIN); - bus_dmamap_sync(atsc->dmatag, atsc->tx_map, BUS_DMASYNC_PREWRITE); - uart_lock(sc->sc_hwmtx); + if (bus_dmamap_load(atsc->tx_tag, atsc->tx_map, sc->sc_txbuf, + sc->sc_txdatasz, at91_getaddr, &addr, 0) != 0) { + err = EAGAIN; + goto errout; + } + bus_dmamap_sync(atsc->tx_tag, atsc->tx_map, BUS_DMASYNC_PREWRITE); sc->sc_txbusy = 1; /* * Setup the PDC to transfer the data and interrupt us when it @@ -433,9 +457,11 @@ at91_usart_bus_transmit(struct uart_soft WR4(&sc->sc_bas, PDC_TCR, sc->sc_txdatasz); WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_TXTEN); WR4(&sc->sc_bas, USART_IER, USART_CSR_ENDTX); +errout: uart_unlock(sc->sc_hwmtx); - return (0); + return (err); } + static int at91_usart_bus_setsig(struct uart_softc *sc, int sig) { @@ -465,12 +491,14 @@ at91_usart_bus_setsig(struct uart_softc uart_unlock(sc->sc_hwmtx); return (0); } + static int at91_usart_bus_receive(struct uart_softc *sc) { return (0); } + static int at91_usart_bus_param(struct uart_softc *sc, int baudrate, int databits, int stopbits, int parity) @@ -488,33 +516,31 @@ at91_rx_put(struct uart_softc *sc, int k if (sc->sc_sysdev != NULL && sc->sc_sysdev->type == UART_DEV_CONSOLE) kdb_alt_break(key, &sc->sc_altbrk); #endif - uart_rx_put(sc, key); + uart_rx_put(sc, key); } static int at91_usart_bus_ipend(struct uart_softc *sc) { - int csr = RD4(&sc->sc_bas, USART_CSR); - int ipend = 0, i, len; struct at91_usart_softc *atsc; struct at91_usart_rx *p; + int i, ipend, len; + uint32_t csr; - atsc = (struct at91_usart_softc *)sc; + ipend = 0; + atsc = (struct at91_usart_softc *)sc; + uart_lock(sc->sc_hwmtx); + csr = RD4(&sc->sc_bas, USART_CSR); if (csr & USART_CSR_ENDTX) { - bus_dmamap_sync(atsc->dmatag, atsc->tx_map, + bus_dmamap_sync(atsc->tx_tag, atsc->tx_map, BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(atsc->dmatag, atsc->tx_map); + bus_dmamap_unload(atsc->tx_tag, atsc->tx_map); } - uart_lock(sc->sc_hwmtx); - if (csr & USART_CSR_TXRDY) { - if (sc->sc_txbusy) - ipend |= SER_INT_TXIDLE; - WR4(&sc->sc_bas, USART_IDR, USART_CSR_TXRDY); - } - if (csr & USART_CSR_ENDTX) { + if (csr & (USART_CSR_TXRDY | USART_CSR_ENDTX)) { if (sc->sc_txbusy) ipend |= SER_INT_TXIDLE; - WR4(&sc->sc_bas, USART_IDR, USART_CSR_ENDTX); + WR4(&sc->sc_bas, USART_IDR, csr & (USART_CSR_TXRDY | + USART_CSR_ENDTX)); } /* @@ -523,90 +549,103 @@ at91_usart_bus_ipend(struct uart_softc * * and do all the work elsewhere. I need to look at the CSR * bits right now and do things based on them to avoid races. */ - if ((atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_RXBUFF)) { - // Have a buffer overflow. Copy all data from both - // ping and pong. Insert overflow character. Reset - // ping and pong and re-enable the PDC to receive - // characters again. - bus_dmamap_sync(atsc->dmatag, atsc->ping->map, - BUS_DMASYNC_POSTREAD); - bus_dmamap_sync(atsc->dmatag, atsc->pong->map, - BUS_DMASYNC_POSTREAD); - for (i = 0; i < sc->sc_rxfifosz; i++) - at91_rx_put(sc, atsc->ping->buffer[i]); - for (i = 0; i < sc->sc_rxfifosz; i++) - at91_rx_put(sc, atsc->pong->buffer[i]); - uart_rx_put(sc, UART_STAT_OVERRUN); - csr &= ~(USART_CSR_ENDRX | USART_CSR_TIMEOUT); - WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); - WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); - WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); - WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); - WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); - ipend |= SER_INT_RXREADY; - } - if ((atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_ENDRX)) { - // Shuffle data from 'ping' of ping pong buffer, but - // leave current 'pong' in place, as it has become the - // new 'ping'. We need to copy data and setup the old - // 'ping' as the new 'pong' when we're done. - bus_dmamap_sync(atsc->dmatag, atsc->ping->map, - BUS_DMASYNC_POSTREAD); - for (i = 0; i < sc->sc_rxfifosz; i++) - at91_rx_put(sc, atsc->ping->buffer[i]); - p = atsc->ping; - atsc->ping = atsc->pong; - atsc->pong = p; - WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); - WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); - ipend |= SER_INT_RXREADY; - } - if ((atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_TIMEOUT)) { - // We have one partial buffer. We need to stop the - // PDC, get the number of characters left and from - // that compute number of valid characters. We then - // need to reset ping and pong and reenable the PDC. - // Not sure if there's a race here at fast baud rates - // we need to worry about. - WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTDIS); - bus_dmamap_sync(atsc->dmatag, atsc->ping->map, - BUS_DMASYNC_POSTREAD); - len = sc->sc_rxfifosz - RD4(&sc->sc_bas, PDC_RCR); - for (i = 0; i < len; i++) - at91_rx_put(sc, atsc->ping->buffer[i]); - WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); - WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); - WR4(&sc->sc_bas, USART_CR, USART_CR_STTTO); - WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); - ipend |= SER_INT_RXREADY; - } - if (!(atsc->flags & HAS_TIMEOUT) && (csr & USART_CSR_RXRDY)) { - // We have another charater in a device that doesn't support - // timeouts, so we do it one character at a time. + if (atsc->flags & HAS_TIMEOUT) { + if (csr & USART_CSR_RXBUFF) { + /* + * We have a buffer overflow. Copy all data from both + * ping and pong. Insert overflow character. Reset + * ping and pong and re-enable the PDC to receive + * characters again. + */ + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_POSTREAD); + bus_dmamap_sync(atsc->rx_tag, atsc->pong->map, + BUS_DMASYNC_POSTREAD); + for (i = 0; i < sc->sc_rxfifosz; i++) + at91_rx_put(sc, atsc->ping->buffer[i]); + for (i = 0; i < sc->sc_rxfifosz; i++) + at91_rx_put(sc, atsc->pong->buffer[i]); + uart_rx_put(sc, UART_STAT_OVERRUN); + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_PREREAD); + bus_dmamap_sync(atsc->rx_tag, atsc->pong->map, + BUS_DMASYNC_PREREAD); + WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); + WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); + WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); + WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); + WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); + ipend |= SER_INT_RXREADY; + } else if (csr & USART_CSR_ENDRX) { + /* + * Shuffle data from ping of ping pong buffer, but + * leave current pong in place, as it has become the + * new ping. We need to copy data and setup the old + * ping as the new pong when we're done. + */ + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_POSTREAD); + for (i = 0; i < sc->sc_rxfifosz; i++) + at91_rx_put(sc, atsc->ping->buffer[i]); + p = atsc->ping; + atsc->ping = atsc->pong; + atsc->pong = p; + bus_dmamap_sync(atsc->rx_tag, atsc->pong->map, + BUS_DMASYNC_PREREAD); + WR4(&sc->sc_bas, PDC_RNPR, atsc->pong->pa); + WR4(&sc->sc_bas, PDC_RNCR, sc->sc_rxfifosz); + ipend |= SER_INT_RXREADY; + } else if (csr & USART_CSR_TIMEOUT) { + /* + * We have one partial buffer. We need to stop the + * PDC, get the number of characters left and from + * that compute number of valid characters. We then + * need to reset ping and pong and reenable the PDC. + * Not sure if there's a race here at fast baud rates + * we need to worry about. + */ + WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTDIS); + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_POSTREAD); + len = sc->sc_rxfifosz - RD4(&sc->sc_bas, PDC_RCR); + for (i = 0; i < len; i++) + at91_rx_put(sc, atsc->ping->buffer[i]); + bus_dmamap_sync(atsc->rx_tag, atsc->ping->map, + BUS_DMASYNC_PREREAD); + WR4(&sc->sc_bas, PDC_RPR, atsc->ping->pa); + WR4(&sc->sc_bas, PDC_RCR, sc->sc_rxfifosz); + WR4(&sc->sc_bas, USART_CR, USART_CR_STTTO); + WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_RXTEN); + ipend |= SER_INT_RXREADY; + } + } else if (csr & USART_CSR_RXRDY) { + /* + * We have another charater in a device that doesn't support + * timeouts, so we do it one character at a time. + */ at91_rx_put(sc, RD4(&sc->sc_bas, USART_RHR) & 0xff); ipend |= SER_INT_RXREADY; } if (csr & USART_CSR_RXBRK) { - unsigned int cr = USART_CR_RSTSTA; - ipend |= SER_INT_BREAK; - WR4(&sc->sc_bas, USART_CR, cr); + WR4(&sc->sc_bas, USART_CR, USART_CR_RSTSTA); } uart_unlock(sc->sc_hwmtx); return (ipend); } + static int at91_usart_bus_flush(struct uart_softc *sc, int what) { + return (0); } static int at91_usart_bus_getsig(struct uart_softc *sc) { - uint32_t new, sig; - uint8_t csr; + uint32_t csr, new, sig; uart_lock(sc->sc_hwmtx); csr = RD4(&sc->sc_bas, USART_CSR); @@ -628,6 +667,7 @@ at91_usart_bus_getsig(struct uart_softc static int at91_usart_bus_ioctl(struct uart_softc *sc, int request, intptr_t data) { + switch (request) { case UART_IOCTL_BREAK: case UART_IOCTL_IFLOW: @@ -637,7 +677,7 @@ at91_usart_bus_ioctl(struct uart_softc * /* only if we know our master clock rate */ if (DEFAULT_RCLK != 0) WR4(&sc->sc_bas, USART_BRGR, - BAUD2DIVISOR(*(int *)data)); + BAUD2DIVISOR(*(int *)data)); return (0); } return (EINVAL); From owner-svn-src-head@FreeBSD.ORG Tue May 1 21:04:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFBBF106564A; Tue, 1 May 2012 21:04:21 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) by mx1.freebsd.org (Postfix) with ESMTP id 62BD78FC16; Tue, 1 May 2012 21:04:21 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 3D18025D3897; Tue, 1 May 2012 21:04:20 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 61FAEBE609C; Tue, 1 May 2012 21:04:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id fK-Iz+8yRJ8u; Tue, 1 May 2012 21:04:18 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id EF5E8BE609E; Tue, 1 May 2012 21:04:17 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201205011716.q41HG1fL036603@svn.freebsd.org> Date: Tue, 1 May 2012 21:04:17 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <25AED007-FC77-46EB-95AF-9715D33A486E@lists.zabbadoz.net> References: <201205011716.q41HG1fL036603@svn.freebsd.org> To: Marius Strobl X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234898 - in head/sys/boot: ofw/libofw sparc64 sparc64/boot1 sparc64/loader sparc64/zfsboot sparc64/zfsloader zfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 21:04:22 -0000 On 1. May 2012, at 17:16 , Marius Strobl wrote: > Author: marius > Date: Tue May 1 17:16:01 2012 > New Revision: 234898 > URL: http://svn.freebsd.org/changeset/base/234898 >=20 > Log: > Add initial support for booting from ZFS on sparc64. At least on Sun = Fire > V100, the firmware is known to be broken and not allowing to = simultaneously > open disk devices, causing attempts to boot from a mirror or RAIDZ to = cause > a crash. This will be worked around later. The firmwares of newer = sun4u models > don't seem to exhibit this problem though. >=20 > Steps for ZFS booting: >=20 > 1. create VTOC8 label > # gpart create -s vtoc8 da0 >=20 > 2. add partitions, f.e.: > # gpart add -t freebsd-zfs -s 60g da0 > # gpart add -t freebsd-swap da0 > resulting in something like: > # gpart show > =3D> 0 143331930 da0 VTOC8 (68G) > 0 125821080 1 freebsd-zfs (60G) > 125821080 17510850 2 freebsd-swap (8.4G) >=20 > 3. create zpool > # zpool create bunker da0a > or for mirror/RAIDZ (after preparing additional disks as in steps 1. = + 2.): > # zpool create bunker mirror da0a da1a > # zpool create bunker raidz da0a da1a da2a ... >=20 > 4. set bootfs > # zpool set bootfs=3Dbunker bunker >=20 > 5. install zfsboot > # zpool export bunker > # gpart bootcode -p /boot/zfsboot da0 >=20 > 6. write zfsloader to the ZFS Boot Block (so far, there's no = dedicated tool > for this, so dd(1) has to be used for this purpose) > When using mirror/RAIDZ, step 4. and the dd(1) invocation should be = repeated > for the additional disks in order to be able to boot from another = disk in > case of failure. > # sysctl kern.geom.debugflags=3D0x10 > # dd if=3D/boot/zfsloader of=3D/dev/da0a bs=3D512 oseek=3D1024 = conv=3Dnotrunc > # zpool import bunker >=20 > 7. install system on ZFS filesystem > Don't forget to set 'zfs_load=3D"YES"' and = vfs.root.mountfrom=3D"zfs:bunker" in > loader.conf as well as 'zfs_enable=3D"YES"'in rc.conf. >=20 > 8. copy zpool.cache to the ZFS filesystem > cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache >=20 > 9. set mountpoint > # zfs set mountpoint=3D/ bunker >=20 > 10. Now, given that aliases for all disks in the zpool exists (check = with > the `devalias` command on the boot monitor prompt) and disk0 = corresponds > to da0 (likewise for additional disks), the system can be booted from = the > ZFS with: > {1} ok boot disk0 These steps belong into documentation (man page, handbook, ...) bit not = really into the commit message. Great news for spacr64 users however, I think. --=20 Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do! From owner-svn-src-head@FreeBSD.ORG Tue May 1 21:05:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5FAC6106566C; Tue, 1 May 2012 21:05:42 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) by mx1.freebsd.org (Postfix) with ESMTP id F2A998FC15; Tue, 1 May 2012 21:05:41 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 12A5125D3897; Tue, 1 May 2012 21:05:41 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 82BD3BE609D; Tue, 1 May 2012 21:05:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id 4cIY23JQaYwI; Tue, 1 May 2012 21:05:39 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 1CEA8BE609C; Tue, 1 May 2012 21:05:39 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201205011615.q41GFZa1034278@svn.freebsd.org> Date: Tue, 1 May 2012 21:05:38 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201205011615.q41GFZa1034278@svn.freebsd.org> To: Monthadar Al Jaberi X-Mailer: Apple Mail (2.1084) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234893 - head/sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 21:05:42 -0000 On 1. May 2012, at 16:15 , Monthadar Al Jaberi wrote: > Author: monthadar > Date: Tue May 1 16:15:34 2012 > New Revision: 234893 > URL: http://svn.freebsd.org/changeset/base/234893 >=20 > Log: > * Added new command to ifconfig to activate Mesh Gate Announcement = called > meshgate with corresponding explanation; >=20 > Approved by: adrian >=20 > Modified: > head/sbin/ifconfig/ifconfig.8 > head/sbin/ifconfig/ifieee80211.c >=20 > Modified: head/sbin/ifconfig/ifconfig.8 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sbin/ifconfig/ifconfig.8 Tue May 1 16:14:18 2012 = (r234892) > +++ head/sbin/ifconfig/ifconfig.8 Tue May 1 16:15:34 2012 = (r234893) Please update .Dd as well. > @@ -1979,6 +1979,12 @@ Enable or disable forwarding packets by=20 > By default > .Cm meshforward > is enabled. > +.It Cm meshgate > +This attribute specifies whether or not the mesh STA activates mesh = gate > +announcements. > +By default > +.Cm meshgate > +is disabled. > .It Cm meshmetric Ar protocol > Set the specified > .Ar protocol --=20 Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do! From owner-svn-src-head@FreeBSD.ORG Tue May 1 21:23:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F2C0B1065675; Tue, 1 May 2012 21:23:21 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 861308FC16; Tue, 1 May 2012 21:23:21 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.4/8.14.4/ALCHEMY.FRANKEN.DE) with ESMTP id q41LNKv7048468; Tue, 1 May 2012 23:23:20 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.4/8.14.4/Submit) id q41LNK9l048467; Tue, 1 May 2012 23:23:20 +0200 (CEST) (envelope-from marius) Date: Tue, 1 May 2012 23:23:19 +0200 From: Marius Strobl To: "Bjoern A. Zeeb" Message-ID: <20120501212319.GF18650@alchemy.franken.de> References: <201205011716.q41HG1fL036603@svn.freebsd.org> <25AED007-FC77-46EB-95AF-9715D33A486E@lists.zabbadoz.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25AED007-FC77-46EB-95AF-9715D33A486E@lists.zabbadoz.net> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@freebsd.org, Marius Strobl , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r234898 - in head/sys/boot: ofw/libofw sparc64 sparc64/boot1 sparc64/loader sparc64/zfsboot sparc64/zfsloader zfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2012 21:23:22 -0000 On Tue, May 01, 2012 at 09:04:17PM +0000, Bjoern A. Zeeb wrote: > > On 1. May 2012, at 17:16 , Marius Strobl wrote: > > > Author: marius > > Date: Tue May 1 17:16:01 2012 > > New Revision: 234898 > > URL: http://svn.freebsd.org/changeset/base/234898 > > > > Log: > > Add initial support for booting from ZFS on sparc64. At least on Sun Fire > > V100, the firmware is known to be broken and not allowing to simultaneously > > open disk devices, causing attempts to boot from a mirror or RAIDZ to cause > > a crash. This will be worked around later. The firmwares of newer sun4u models > > don't seem to exhibit this problem though. > > > > Steps for ZFS booting: > > > > 1. create VTOC8 label > > # gpart create -s vtoc8 da0 > > > > 2. add partitions, f.e.: > > # gpart add -t freebsd-zfs -s 60g da0 > > # gpart add -t freebsd-swap da0 > > resulting in something like: > > # gpart show > > => 0 143331930 da0 VTOC8 (68G) > > 0 125821080 1 freebsd-zfs (60G) > > 125821080 17510850 2 freebsd-swap (8.4G) > > > > 3. create zpool > > # zpool create bunker da0a > > or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.): > > # zpool create bunker mirror da0a da1a > > # zpool create bunker raidz da0a da1a da2a ... > > > > 4. set bootfs > > # zpool set bootfs=bunker bunker > > > > 5. install zfsboot > > # zpool export bunker > > # gpart bootcode -p /boot/zfsboot da0 > > > > 6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool > > for this, so dd(1) has to be used for this purpose) > > When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated > > for the additional disks in order to be able to boot from another disk in > > case of failure. > > # sysctl kern.geom.debugflags=0x10 > > # dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc > > # zpool import bunker > > > > 7. install system on ZFS filesystem > > Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in > > loader.conf as well as 'zfs_enable="YES"'in rc.conf. > > > > 8. copy zpool.cache to the ZFS filesystem > > cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache > > > > 9. set mountpoint > > # zfs set mountpoint=/ bunker > > > > 10. Now, given that aliases for all disks in the zpool exists (check with > > the `devalias` command on the boot monitor prompt) and disk0 corresponds > > to da0 (likewise for additional disks), the system can be booted from the > > ZFS with: > > {1} ok boot disk0 > > > These steps belong into documentation (man page, handbook, ...) bit not really > into the commit message. > We've seen way larger commit messages across totally unrelated parts in the past and the commit message seemed like a good place for ensuring the instructions not getting lost for now ... In any case, I'm desperately waiting for property editing on svn:log to be enabled :) Marius From owner-svn-src-head@FreeBSD.ORG Wed May 2 01:14:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE2F5106566B; Wed, 2 May 2012 01:14:15 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9A1488FC08; Wed, 2 May 2012 01:14:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q421EFvM056610; Wed, 2 May 2012 01:14:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q421EFrA056608; Wed, 2 May 2012 01:14:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020114.q421EFrA056608@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 01:14:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234905 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 01:14:15 -0000 Author: adrian Date: Wed May 2 01:14:15 2012 New Revision: 234905 URL: http://svn.freebsd.org/changeset/base/234905 Log: Introduce an enum which encapsulates the PHY interface types that can be configured. Modified: head/sys/mips/atheros/ar71xxreg.h Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Wed May 2 00:31:09 2012 (r234904) +++ head/sys/mips/atheros/ar71xxreg.h Wed May 2 01:14:15 2012 (r234905) @@ -267,6 +267,13 @@ #define AR91XX_REV_ID_REVISION_MASK 0x3 #define AR91XX_REV_ID_REVISION_SHIFT 2 +typedef enum { + AR71XX_MII_MODE_NONE = 0, + AR71XX_MII_MODE_GMII, + AR71XX_MII_MODE_MII, + AR71XX_MII_MODE_RGMII, + AR71XX_MII_MODE_RMII, +} ar71xx_mii_mode; /* * AR71xx MII control region */ @@ -288,7 +295,6 @@ #define MII1_CTRL_IF_RGMII 0 #define MII1_CTRL_IF_RMII 1 - /* * GigE adapters region */ From owner-svn-src-head@FreeBSD.ORG Wed May 2 01:21:58 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6AF1C106564A; Wed, 2 May 2012 01:21:58 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5547A8FC0A; Wed, 2 May 2012 01:21:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q421LwUs056905; Wed, 2 May 2012 01:21:58 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q421LwFU056899; Wed, 2 May 2012 01:21:58 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020121.q421LwFU056899@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 01:21:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234906 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 01:21:58 -0000 Author: adrian Date: Wed May 2 01:21:57 2012 New Revision: 234906 URL: http://svn.freebsd.org/changeset/base/234906 Log: MII related infrastructure changes. * Add a new method to set the MII mode - GMII, RGMII, RMII, MII. + arge0 supports all four (two for non-Gige interfaces.) + arge1 only supports two (one for non-gige interfaces.) * Set the MII clock speed when changing the MAC PLL speed. + Needed for AR91xx and AR71xx; not needed for AR724x. Tested: * AR71xx only, I'll do AR913x testing tonight and fix whichever issues creep up. TODO: * Implement the missing AR7242 arge0 PLL configuration, but don't adjust the MII speed accordingly. * .. the AR7240/AR7241 don't require this, so make sure it's not set accidentally. Bugs (not fixed here): * Statically configured arge speeds are still broken - investigate why that is on the AP96 board. Autonegotiate is working fine, but there still seems to be an occasionally heavy packet loss issue. Obtained from: Linux/Atheros/OpenWRT Modified: head/sys/mips/atheros/ar71xx_chip.c head/sys/mips/atheros/ar71xx_chip.h head/sys/mips/atheros/ar71xx_cpudef.h head/sys/mips/atheros/ar724x_chip.c head/sys/mips/atheros/ar91xx_chip.c Modified: head/sys/mips/atheros/ar71xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.c Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar71xx_chip.c Wed May 2 01:21:57 2012 (r234906) @@ -176,6 +176,50 @@ ar71xx_chip_set_mii_speed(uint32_t unit, ATH_WRITE_REG(reg, val); } +void +ar71xx_chip_set_mii_if(uint32_t unit, uint32_t mii_mode) +{ + uint32_t val, reg, mii_if; + + switch (unit) { + case 0: + reg = AR71XX_MII0_CTRL; + if (mii_mode == AR71XX_MII_MODE_GMII) + mii_if = MII0_CTRL_IF_GMII; + else if (mii_mode == AR71XX_MII_MODE_MII) + mii_if = MII0_CTRL_IF_MII; + else if (mii_mode == AR71XX_MII_MODE_RGMII) + mii_if = MII0_CTRL_IF_RGMII; + else if (mii_mode == AR71XX_MII_MODE_RMII) + mii_if = MII0_CTRL_IF_RMII; + else + printf("%s: invalid MII mode (%d) for unit %d\n", + __func__, mii_mode, unit); + return; + break; + case 1: + reg = AR71XX_MII1_CTRL; + if (mii_mode == AR71XX_MII_MODE_RGMII) + mii_if = MII1_CTRL_IF_RGMII; + if (mii_mode == AR71XX_MII_MODE_RMII) + mii_if = MII1_CTRL_IF_RMII; + else + printf("%s: invalid MII mode (%d) for unit %d\n", + __func__, mii_mode, unit); + return; + break; + default: + printf("%s: invalid MII unit set for arge unit: %d\n", + __func__, unit); + return; + } + + val = ATH_READ_REG(reg); + val &= ~(MII_CTRL_IF_MASK << MII_CTRL_IF_SHIFT); + val |= (mii_if & MII_CTRL_IF_MASK) << MII_CTRL_IF_SHIFT; + ATH_WRITE_REG(reg, val); +} + /* Speed is either 10, 100 or 1000 */ static void ar71xx_chip_set_pll_ge(int unit, int speed) @@ -197,6 +241,7 @@ ar71xx_chip_set_pll_ge(int unit, int spe __func__, unit, speed); return; } + switch (unit) { case 0: ar71xx_write_pll(AR71XX_PLL_SEC_CONFIG, @@ -213,6 +258,12 @@ ar71xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } + + /* + * AR71xx and AR913x require this; AR724x doesn't require + * an MII clock change at all. + */ + ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -278,6 +329,7 @@ struct ar71xx_cpu_def ar71xx_chip_def = &ar71xx_chip_device_stopped, &ar71xx_chip_set_pll_ge, &ar71xx_chip_set_mii_speed, + &ar71xx_chip_set_mii_if, &ar71xx_chip_ddr_flush_ge, &ar71xx_chip_get_eth_pll, &ar71xx_chip_ddr_flush_ip2, Modified: head/sys/mips/atheros/ar71xx_chip.h ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.h Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar71xx_chip.h Wed May 2 01:21:57 2012 (r234906) @@ -31,5 +31,6 @@ extern struct ar71xx_cpu_def ar71xx_chip_def; extern void ar71xx_chip_set_mii_speed(uint32_t unit, uint32_t speed); +extern void ar71xx_chip_set_mii_if(uint32_t unit, uint32_t mii_if); #endif Modified: head/sys/mips/atheros/ar71xx_cpudef.h ============================================================================== --- head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 01:21:57 2012 (r234906) @@ -37,6 +37,7 @@ struct ar71xx_cpu_def { int (* ar71xx_chip_device_stopped) (uint32_t); void (* ar71xx_chip_set_pll_ge) (int, int); void (* ar71xx_chip_set_mii_speed) (uint32_t, uint32_t); + void (* ar71xx_chip_set_mii_if) (uint32_t, ar71xx_mii_mode); void (* ar71xx_chip_ddr_flush_ge) (int); uint32_t (* ar71xx_chip_get_eth_pll) (unsigned int, int); @@ -90,6 +91,11 @@ static inline void ar71xx_device_set_mii ar71xx_cpu_ops->ar71xx_chip_set_mii_speed(unit, speed); } +static inline void ar71xx_device_set_mii_if(int unit, ar71xx_mii_mode mii_cfg) +{ + ar71xx_cpu_ops->ar71xx_chip_set_mii_if(unit, mii_cfg); +} + static inline void ar71xx_device_flush_ddr_ge(int unit) { ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge(unit); Modified: head/sys/mips/atheros/ar724x_chip.c ============================================================================== --- head/sys/mips/atheros/ar724x_chip.c Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar724x_chip.c Wed May 2 01:21:57 2012 (r234906) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -130,6 +131,13 @@ ar724x_chip_set_mii_speed(uint32_t unit, return; } +/* + * XXX TODO: set the PLL for arge0 only on AR7242. + * The PLL/clock requirements are different. + * + * Otherwise, it's a NULL function for AR7240, AR7241 and + * AR7242 arge1. + */ static void ar724x_chip_set_pll_ge(int unit, int speed) { @@ -229,6 +237,7 @@ struct ar71xx_cpu_def ar724x_chip_def = &ar724x_chip_device_stopped, &ar724x_chip_set_pll_ge, &ar724x_chip_set_mii_speed, + &ar71xx_chip_set_mii_if, &ar724x_chip_ddr_flush_ge, &ar724x_chip_get_eth_pll, &ar724x_chip_ddr_flush_ip2, Modified: head/sys/mips/atheros/ar91xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar91xx_chip.c Wed May 2 01:14:15 2012 (r234905) +++ head/sys/mips/atheros/ar91xx_chip.c Wed May 2 01:21:57 2012 (r234906) @@ -147,6 +147,7 @@ ar91xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } + ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -211,6 +212,7 @@ struct ar71xx_cpu_def ar91xx_chip_def = &ar91xx_chip_device_stopped, &ar91xx_chip_set_pll_ge, &ar71xx_chip_set_mii_speed, + &ar71xx_chip_set_mii_if, &ar91xx_chip_ddr_flush_ge, &ar91xx_chip_get_eth_pll, &ar91xx_chip_ddr_flush_ip2, From owner-svn-src-head@FreeBSD.ORG Wed May 2 04:51:44 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1ECA106566C; Wed, 2 May 2012 04:51:44 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ACBE98FC08; Wed, 2 May 2012 04:51:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q424pigx064972; Wed, 2 May 2012 04:51:44 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q424pi8N064966; Wed, 2 May 2012 04:51:44 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020451.q424pi8N064966@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 04:51:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234907 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 04:51:44 -0000 Author: adrian Date: Wed May 2 04:51:43 2012 New Revision: 234907 URL: http://svn.freebsd.org/changeset/base/234907 Log: Further ar71xx MII support improvements. * Flesh out the PLL configuration fetch function, which will return the PLL configuration based on the unit number and speed. * Remove the PLL speed config logic from the AR71xx/AR91xx chip PLL config function - pass in a 'pll' value instead. * Modify arge_set_pll() to: + fetch the PLL configuration + write the PLL configuration + update the MII speed configuration. This will allow if_arge to override the PLL configuration as required. Obtained from: Linux/Atheros/OpenWRT Modified: head/sys/mips/atheros/ar71xx_chip.c head/sys/mips/atheros/ar71xx_cpudef.h head/sys/mips/atheros/ar724x_chip.c head/sys/mips/atheros/ar91xx_chip.c head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/ar71xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar71xx_chip.c Wed May 2 04:51:43 2012 (r234907) @@ -222,25 +222,8 @@ ar71xx_chip_set_mii_if(uint32_t unit, ui /* Speed is either 10, 100 or 1000 */ static void -ar71xx_chip_set_pll_ge(int unit, int speed) +ar71xx_chip_set_pll_ge(int unit, int speed, uint32_t pll) { - uint32_t pll; - - switch (speed) { - case 10: - pll = PLL_ETH_INT_CLK_10; - break; - case 100: - pll = PLL_ETH_INT_CLK_100; - break; - case 1000: - pll = PLL_ETH_INT_CLK_1000; - break; - default: - printf("%s%d: invalid speed %d\n", - __func__, unit, speed); - return; - } switch (unit) { case 0: @@ -258,12 +241,6 @@ ar71xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } - - /* - * AR71xx and AR913x require this; AR724x doesn't require - * an MII clock change at all. - */ - ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -293,7 +270,24 @@ ar71xx_chip_ddr_flush_ip2(void) static uint32_t ar71xx_chip_get_eth_pll(unsigned int mac, int speed) { - return 0; + uint32_t pll; + + switch (speed) { + case 10: + pll = PLL_ETH_INT_CLK_10; + break; + case 100: + pll = PLL_ETH_INT_CLK_100; + break; + case 1000: + pll = PLL_ETH_INT_CLK_1000; + break; + default: + printf("%s%d: invalid speed %d\n", __func__, mac, speed); + pll = 0; + } + + return (pll); } static void Modified: head/sys/mips/atheros/ar71xx_cpudef.h ============================================================================== --- head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar71xx_cpudef.h Wed May 2 04:51:43 2012 (r234907) @@ -35,7 +35,7 @@ struct ar71xx_cpu_def { void (* ar71xx_chip_device_stop) (uint32_t); void (* ar71xx_chip_device_start) (uint32_t); int (* ar71xx_chip_device_stopped) (uint32_t); - void (* ar71xx_chip_set_pll_ge) (int, int); + void (* ar71xx_chip_set_pll_ge) (int, int, uint32_t); void (* ar71xx_chip_set_mii_speed) (uint32_t, uint32_t); void (* ar71xx_chip_set_mii_if) (uint32_t, ar71xx_mii_mode); void (* ar71xx_chip_ddr_flush_ge) (int); @@ -81,9 +81,9 @@ static inline int ar71xx_device_stopped( return ar71xx_cpu_ops->ar71xx_chip_device_stopped(mask); } -static inline void ar71xx_device_set_pll_ge(int unit, int speed) +static inline void ar71xx_device_set_pll_ge(int unit, int speed, uint32_t pll) { - ar71xx_cpu_ops->ar71xx_chip_set_pll_ge(unit, speed); + ar71xx_cpu_ops->ar71xx_chip_set_pll_ge(unit, speed, pll); } static inline void ar71xx_device_set_mii_speed(int unit, int speed) @@ -101,6 +101,11 @@ static inline void ar71xx_device_flush_d ar71xx_cpu_ops->ar71xx_chip_ddr_flush_ge(unit); } +static inline uint32_t ar71xx_device_get_eth_pll(unsigned int unit, int speed) +{ + return (ar71xx_cpu_ops->ar71xx_chip_get_eth_pll(unit, speed)); +} + static inline void ar71xx_init_usb_peripheral(void) { ar71xx_cpu_ops->ar71xx_chip_init_usb_peripheral(); Modified: head/sys/mips/atheros/ar724x_chip.c ============================================================================== --- head/sys/mips/atheros/ar724x_chip.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar724x_chip.c Wed May 2 04:51:43 2012 (r234907) @@ -139,7 +139,7 @@ ar724x_chip_set_mii_speed(uint32_t unit, * AR7242 arge1. */ static void -ar724x_chip_set_pll_ge(int unit, int speed) +ar724x_chip_set_pll_ge(int unit, int speed, uint32_t pll) { switch (unit) { @@ -185,7 +185,7 @@ static uint32_t ar724x_chip_get_eth_pll(unsigned int mac, int speed) { - return 0; + return (0); } static void Modified: head/sys/mips/atheros/ar91xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar91xx_chip.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/ar91xx_chip.c Wed May 2 04:51:43 2012 (r234907) @@ -112,25 +112,9 @@ ar91xx_chip_device_stopped(uint32_t mask } static void -ar91xx_chip_set_pll_ge(int unit, int speed) +ar91xx_chip_set_pll_ge(int unit, int speed, uint32_t pll) { - uint32_t pll; - switch(speed) { - case 10: - pll = AR91XX_PLL_VAL_10; - break; - case 100: - pll = AR91XX_PLL_VAL_100; - break; - case 1000: - pll = AR91XX_PLL_VAL_1000; - break; - default: - printf("%s%d: invalid speed %d\n", - __func__, unit, speed); - return; - } switch (unit) { case 0: ar71xx_write_pll(AR91XX_PLL_REG_ETH_CONFIG, @@ -147,7 +131,6 @@ ar91xx_chip_set_pll_ge(int unit, int spe __func__, unit); return; } - ar71xx_chip_set_mii_speed(unit, speed); } static void @@ -179,8 +162,24 @@ ar91xx_chip_ddr_flush_ip2(void) static uint32_t ar91xx_chip_get_eth_pll(unsigned int mac, int speed) { + uint32_t pll; + + switch(speed) { + case 10: + pll = AR91XX_PLL_VAL_10; + break; + case 100: + pll = AR91XX_PLL_VAL_100; + break; + case 1000: + pll = AR91XX_PLL_VAL_1000; + break; + default: + printf("%s%d: invalid speed %d\n", __func__, mac, speed); + pll = 0; + } - return 0; + return (pll); } static void Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Wed May 2 01:21:57 2012 (r234906) +++ head/sys/mips/atheros/if_arge.c Wed May 2 04:51:43 2012 (r234907) @@ -776,10 +776,13 @@ arge_update_link_locked(struct arge_soft if (mii->mii_media_status & IFM_ACTIVE) { media = IFM_SUBTYPE(mii->mii_media_active); - if (media != IFM_NONE) { sc->arge_link_status = 1; duplex = mii->mii_media_active & IFM_GMASK; + ARGEDEBUG(sc, ARGE_DBG_MII, "%s: media=%d, duplex=%d\n", + __func__, + media, + duplex); arge_set_pll(sc, media, duplex); } } else { @@ -791,7 +794,7 @@ static void arge_set_pll(struct arge_softc *sc, int media, int duplex) { uint32_t cfg, ifcontrol, rx_filtmask; - uint32_t fifo_tx; + uint32_t fifo_tx, pll; int if_speed; ARGEDEBUG(sc, ARGE_DBG_MII, "set_pll(%04x, %s)\n", media, @@ -832,6 +835,8 @@ arge_set_pll(struct arge_softc *sc, int "Unknown media %d\n", media); } + ARGEDEBUG(sc, ARGE_DBG_MII, "%s: if_speed=%d\n", __func__, if_speed); + switch (ar71xx_soc) { case AR71XX_SOC_AR7240: case AR71XX_SOC_AR7241: @@ -853,7 +858,13 @@ arge_set_pll(struct arge_softc *sc, int ARGE_WRITE(sc, AR71XX_MAC_FIFO_TX_THRESHOLD, fifo_tx); /* set PLL registers */ - ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed); + pll = ar71xx_device_get_eth_pll(sc->arge_mac_unit, if_speed); + + /* XXX ensure pll != 0 */ + ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed, pll); + + /* set MII registers */ + ar71xx_device_set_mii_speed(sc->arge_mac_unit, if_speed); } From owner-svn-src-head@FreeBSD.ORG Wed May 2 05:49:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0AD18106564A; Wed, 2 May 2012 05:49:59 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA4068FC16; Wed, 2 May 2012 05:49:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q425nwcg066979; Wed, 2 May 2012 05:49:58 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q425nwet066977; Wed, 2 May 2012 05:49:58 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201205020549.q425nwet066977@svn.freebsd.org> From: Tim Kientzle Date: Wed, 2 May 2012 05:49:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234908 - head/sys/boot/arm/uboot X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 05:49:59 -0000 Author: kientzle Date: Wed May 2 05:49:58 2012 New Revision: 234908 URL: http://svn.freebsd.org/changeset/base/234908 Log: Remove some redundant register loads. Discussed on: arm@ Modified: head/sys/boot/arm/uboot/start.S Modified: head/sys/boot/arm/uboot/start.S ============================================================================== --- head/sys/boot/arm/uboot/start.S Wed May 2 04:51:43 2012 (r234907) +++ head/sys/boot/arm/uboot/start.S Wed May 2 05:49:58 2012 (r234908) @@ -49,27 +49,20 @@ _start: * syscall() */ ENTRY(syscall) - /* Save caller's lr */ + /* Save caller's lr and r8 */ ldr ip, =saved_regs str lr, [ip, #4] - /* Save loader's r8 */ - ldr ip, =saved_regs str r8, [ip, #8] - /* Restore U-Boot's r8 */ - ldr ip, =saved_regs ldr r8, [ip, #0] /* Call into U-Boot */ ldr lr, =return_from_syscall ldr ip, =syscall_ptr ldr pc, [ip] - return_from_syscall: - /* Restore loader's r8 */ + /* Restore loader's r8 and lr */ ldr ip, =saved_regs ldr r8, [ip, #8] - /* Restore caller's lr */ - ldr ip, =saved_regs ldr lr, [ip, #4] /* Return to caller */ mov pc, lr From owner-svn-src-head@FreeBSD.ORG Wed May 2 06:17:17 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2B045106566B; Wed, 2 May 2012 06:17:17 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F0A3B8FC08; Wed, 2 May 2012 06:17:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q426HGs7068133; Wed, 2 May 2012 06:17:16 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426HGV1068131; Wed, 2 May 2012 06:17:16 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020617.q426HGV1068131@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 06:17:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234909 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:17:17 -0000 Author: adrian Date: Wed May 2 06:17:16 2012 New Revision: 234909 URL: http://svn.freebsd.org/changeset/base/234909 Log: Add a missing newline. Modified: head/sys/mips/atheros/ar71xxreg.h Modified: head/sys/mips/atheros/ar71xxreg.h ============================================================================== --- head/sys/mips/atheros/ar71xxreg.h Wed May 2 05:49:58 2012 (r234908) +++ head/sys/mips/atheros/ar71xxreg.h Wed May 2 06:17:16 2012 (r234909) @@ -274,6 +274,7 @@ typedef enum { AR71XX_MII_MODE_RGMII, AR71XX_MII_MODE_RMII, } ar71xx_mii_mode; + /* * AR71xx MII control region */ From owner-svn-src-head@FreeBSD.ORG Wed May 2 06:18:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1254A1065673; Wed, 2 May 2012 06:18:13 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D764D8FC1A; Wed, 2 May 2012 06:18:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q426IC2j068207; Wed, 2 May 2012 06:18:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426ICmG068202; Wed, 2 May 2012 06:18:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020618.q426ICmG068202@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 06:18:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234910 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:18:13 -0000 Author: adrian Date: Wed May 2 06:18:12 2012 New Revision: 234910 URL: http://svn.freebsd.org/changeset/base/234910 Log: Allow the MII mode to be overridden via 'hint.arge.X.miimode'. It takes a number at the moment, rather than a string. Some of the Linux board configurations specify the MII mode explicitly. Modified: head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Wed May 2 06:17:16 2012 (r234909) +++ head/sys/mips/atheros/if_arge.c Wed May 2 06:18:12 2012 (r234910) @@ -103,6 +103,14 @@ typedef enum { ARGE_DBG_RESET = 0x00000020, } arge_debug_flags; +static const char * arge_miicfg_str[] = { + "NONE", + "GMII", + "MII", + "RGMII", + "RMII" +}; + #ifdef ARGE_DEBUG #define ARGEDEBUG(_sc, _m, ...) \ do { \ @@ -333,6 +341,7 @@ arge_attach(device_t dev) int is_base_mac_empty, i; uint32_t hint; long eeprom_mac_addr = 0; + int miicfg = 0; sc = device_get_softc(dev); sc->arge_dev = dev; @@ -363,6 +372,17 @@ arge_attach(device_t dev) ("if_arge: Only MAC0 and MAC1 supported")); /* + * Get the MII configuration, if applicable. + */ + if (resource_int_value(device_get_name(dev), device_get_unit(dev), + "miimode", &miicfg) == 0) { + /* XXX bounds check? */ + device_printf(dev, "%s: overriding MII mode to '%s'\n", + __func__, arge_miicfg_str[miicfg]); + sc->arge_miicfg = miicfg; + } + + /* * Get which PHY of 5 available we should use for this unit */ if (resource_int_value(device_get_name(dev), device_get_unit(dev), @@ -497,6 +517,10 @@ arge_attach(device_t dev) arge_reset_miibus(sc); #endif + /* Configure MII mode, just for convienence */ + if (sc->arge_miicfg != 0) + ar71xx_device_set_mii_if(sc->arge_mac_unit, sc->arge_miicfg); + /* * Set all Ethernet address registers to the same initial values * set all four addresses to 66-88-aa-cc-dd-ee Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Wed May 2 06:17:16 2012 (r234909) +++ head/sys/mips/atheros/if_argevar.h Wed May 2 06:18:12 2012 (r234910) @@ -135,6 +135,7 @@ struct arge_softc { void *arge_intrhand; device_t arge_miibus; device_t arge_miiproxy; + ar71xx_mii_mode arge_miicfg; bus_dma_tag_t arge_parent_tag; bus_dma_tag_t arge_tag; struct mtx arge_mtx; From owner-svn-src-head@FreeBSD.ORG Wed May 2 06:19:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A8284106566B; Wed, 2 May 2012 06:19:26 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 930E28FC0C; Wed, 2 May 2012 06:19:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q426JQI4068280; Wed, 2 May 2012 06:19:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q426JQpk068278; Wed, 2 May 2012 06:19:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020619.q426JQpk068278@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 06:19:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234911 - head/sys/mips/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 06:19:26 -0000 Author: adrian Date: Wed May 2 06:19:26 2012 New Revision: 234911 URL: http://svn.freebsd.org/changeset/base/234911 Log: * Force the ethernet MII configuration to be RGMII * Populate the "pll_1000" field, which will soon be used to override the PLL configuration from the default value. Obtained from: Linux OpenWRT Modified: head/sys/mips/conf/AP96.hints Modified: head/sys/mips/conf/AP96.hints ============================================================================== --- head/sys/mips/conf/AP96.hints Wed May 2 06:18:12 2012 (r234910) +++ head/sys/mips/conf/AP96.hints Wed May 2 06:19:26 2012 (r234911) @@ -16,17 +16,17 @@ hint.mdioproxy.1.at="mdio0" hint.arge.0.phymask=0x0f hint.arge.0.media=1000 hint.arge.0.fduplex=1 +hint.arge.0.miimode=3 # RGMII # For now, rendezouvs this on the arge0 mdiobus. # Later, this will rendezvous via the AR8316 switch. hint.arge.0.mdio=mdioproxy0 # TODO: RGMII -# TODO: pll_1000 = 0x1f000000 hint.arge.1.phymask=0x10 -# hint.arge.1.media=1000 -# hint.arge.1.fduplex=1 +hint.arge.1.pll_1000 = 0x1f000000 # For now, rendezouvs this on the arge0 mdiobus. # Later, this will rendezvous via the AR8316 switch. +hint.arge.1.miimode=3 # RGMII hint.arge.1.mdio=mdioproxy1 # ath0 - slot 17 From owner-svn-src-head@FreeBSD.ORG Wed May 2 07:41:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C23DD106564A; Wed, 2 May 2012 07:41:26 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AD54A8FC08; Wed, 2 May 2012 07:41:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q427fQqF071892; Wed, 2 May 2012 07:41:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q427fQP7071890; Wed, 2 May 2012 07:41:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020741.q427fQP7071890@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 07:41:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234918 - head/sys/mips/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:41:26 -0000 Author: adrian Date: Wed May 2 07:41:26 2012 New Revision: 234918 URL: http://svn.freebsd.org/changeset/base/234918 Log: Disable the pll_1000 hint for now, the upcoming work enables it and it breaks without the switch PHY code. Modified: head/sys/mips/conf/AP96.hints Modified: head/sys/mips/conf/AP96.hints ============================================================================== --- head/sys/mips/conf/AP96.hints Wed May 2 07:22:58 2012 (r234917) +++ head/sys/mips/conf/AP96.hints Wed May 2 07:41:26 2012 (r234918) @@ -23,7 +23,7 @@ hint.arge.0.mdio=mdioproxy0 # TODO: RGMII hint.arge.1.phymask=0x10 -hint.arge.1.pll_1000 = 0x1f000000 +# hint.arge.1.pll_1000 = 0x1f000000 # For now, rendezouvs this on the arge0 mdiobus. # Later, this will rendezvous via the AR8316 switch. hint.arge.1.miimode=3 # RGMII From owner-svn-src-head@FreeBSD.ORG Wed May 2 07:43:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A4B0106566C; Wed, 2 May 2012 07:43:12 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7C768FC12; Wed, 2 May 2012 07:43:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q427hB5U071994; Wed, 2 May 2012 07:43:11 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q427hBCe071991; Wed, 2 May 2012 07:43:11 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205020743.q427hBCe071991@svn.freebsd.org> From: Adrian Chadd Date: Wed, 2 May 2012 07:43:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234919 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 07:43:12 -0000 Author: adrian Date: Wed May 2 07:43:11 2012 New Revision: 234919 URL: http://svn.freebsd.org/changeset/base/234919 Log: Implement PLL configuration override support, similar to what openwrt implements. Modified: head/sys/mips/atheros/if_arge.c head/sys/mips/atheros/if_argevar.h Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Wed May 2 07:41:26 2012 (r234918) +++ head/sys/mips/atheros/if_arge.c Wed May 2 07:43:11 2012 (r234919) @@ -101,6 +101,7 @@ typedef enum { ARGE_DBG_RX = 0x00000008, ARGE_DBG_ERR = 0x00000010, ARGE_DBG_RESET = 0x00000020, + ARGE_DBG_PLL = 0x00000040, } arge_debug_flags; static const char * arge_miicfg_str[] = { @@ -331,6 +332,34 @@ arge_reset_miibus(struct arge_softc *sc) DELAY(100); } +static void +arge_fetch_pll_config(struct arge_softc *sc) +{ + long int val; + + if (resource_long_value(device_get_name(sc->arge_dev), + device_get_unit(sc->arge_dev), + "pll_10", &val) == 0) { + sc->arge_pllcfg.pll_10 = val; + device_printf(sc->arge_dev, "%s: pll_10 = 0x%x\n", + __func__, (int) val); + } + if (resource_long_value(device_get_name(sc->arge_dev), + device_get_unit(sc->arge_dev), + "pll_100", &val) == 0) { + sc->arge_pllcfg.pll_100 = val; + device_printf(sc->arge_dev, "%s: pll_100 = 0x%x\n", + __func__, (int) val); + } + if (resource_long_value(device_get_name(sc->arge_dev), + device_get_unit(sc->arge_dev), + "pll_1000", &val) == 0) { + sc->arge_pllcfg.pll_1000 = val; + device_printf(sc->arge_dev, "%s: pll_1000 = 0x%x\n", + __func__, (int) val); + } +} + static int arge_attach(device_t dev) { @@ -372,6 +401,11 @@ arge_attach(device_t dev) ("if_arge: Only MAC0 and MAC1 supported")); /* + * Fetch the PLL configuration. + */ + arge_fetch_pll_config(sc); + + /* * Get the MII configuration, if applicable. */ if (resource_int_value(device_get_name(dev), device_get_unit(dev), @@ -821,7 +855,7 @@ arge_set_pll(struct arge_softc *sc, int uint32_t fifo_tx, pll; int if_speed; - ARGEDEBUG(sc, ARGE_DBG_MII, "set_pll(%04x, %s)\n", media, + ARGEDEBUG(sc, ARGE_DBG_PLL, "set_pll(%04x, %s)\n", media, duplex == IFM_FDX ? "full" : "half"); cfg = ARGE_READ(sc, AR71XX_MAC_CFG2); cfg &= ~(MAC_CFG2_IFACE_MODE_1000 @@ -859,7 +893,7 @@ arge_set_pll(struct arge_softc *sc, int "Unknown media %d\n", media); } - ARGEDEBUG(sc, ARGE_DBG_MII, "%s: if_speed=%d\n", __func__, if_speed); + ARGEDEBUG(sc, ARGE_DBG_PLL, "%s: if_speed=%d\n", __func__, if_speed); switch (ar71xx_soc) { case AR71XX_SOC_AR7240: @@ -881,8 +915,18 @@ arge_set_pll(struct arge_softc *sc, int rx_filtmask); ARGE_WRITE(sc, AR71XX_MAC_FIFO_TX_THRESHOLD, fifo_tx); - /* set PLL registers */ + /* fetch PLL registers */ pll = ar71xx_device_get_eth_pll(sc->arge_mac_unit, if_speed); + ARGEDEBUG(sc, ARGE_DBG_PLL, "%s: pll=0x%x\n", __func__, pll); + + /* Override if required by platform data */ + if (if_speed == 10 && sc->arge_pllcfg.pll_10 != 0) + pll = sc->arge_pllcfg.pll_10; + else if (if_speed == 100 && sc->arge_pllcfg.pll_100 != 0) + pll = sc->arge_pllcfg.pll_100; + else if (if_speed == 1000 && sc->arge_pllcfg.pll_1000 != 0) + pll = sc->arge_pllcfg.pll_1000; + ARGEDEBUG(sc, ARGE_DBG_PLL, "%s: final pll=0x%x\n", __func__, pll); /* XXX ensure pll != 0 */ ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed, pll); Modified: head/sys/mips/atheros/if_argevar.h ============================================================================== --- head/sys/mips/atheros/if_argevar.h Wed May 2 07:41:26 2012 (r234918) +++ head/sys/mips/atheros/if_argevar.h Wed May 2 07:43:11 2012 (r234919) @@ -118,6 +118,15 @@ struct arge_ring_data { bus_addr_t arge_tx_ring_paddr; }; +/* + * Allow PLL values to be overridden. + */ +struct arge_pll_data { + uint32_t pll_10; + uint32_t pll_100; + uint32_t pll_1000; +}; + struct arge_softc { struct ifnet *arge_ifp; /* interface info */ device_t arge_dev; @@ -136,6 +145,7 @@ struct arge_softc { device_t arge_miibus; device_t arge_miiproxy; ar71xx_mii_mode arge_miicfg; + struct arge_pll_data arge_pllcfg; bus_dma_tag_t arge_parent_tag; bus_dma_tag_t arge_tag; struct mtx arge_mtx; From owner-svn-src-head@FreeBSD.ORG Wed May 2 08:10:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E86C1065672; Wed, 2 May 2012 08:10:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 669E58FC0A; Wed, 2 May 2012 08:10:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q428AG9f073073; Wed, 2 May 2012 08:10:16 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q428AGwg073067; Wed, 2 May 2012 08:10:16 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201205020810.q428AGwg073067@svn.freebsd.org> From: Robert Watson Date: Wed, 2 May 2012 08:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234920 - in head/sys: dev/gxemul dev/gxemul/cons mips/conf mips/gxemul X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 08:10:16 -0000 Author: rwatson Date: Wed May 2 08:10:15 2012 New Revision: 234920 URL: http://svn.freebsd.org/changeset/base/234920 Log: Merge a rudimentary gxemul "oldtestmips" port. This consists almost entirely of one machdep file lifted from the MALTA port, as well as a low-level console and tty driver for the gxemul debugging console device (the emulators stdio). As with many low-level embedded and hypervisor console devices, it is polled only, so we drive TTY I/O from a callout; we are perhaps a bit too aware of the MIPS physical maps in order to attach the console before newbus comes to life. The sample kernel configuration depends on an MD-based root file system, which is not provided. However, any 64-bit, big-endian userspace image (such as one generated for MALTA) should work. This will hopefully be supplemented by additional device drivers for gxemul-specific hardware simulations from Juli Mallett. We have found oldtestmips quite useful for testing and improving aspects of the MIPS port, so it's worth supporting better in FreeBSD. Requested by: theraven, jmallett Sponsored by: DARPA, AFRL MFC after: 3 weeks Added: head/sys/dev/gxemul/ head/sys/dev/gxemul/cons/ head/sys/dev/gxemul/cons/gxemul_cons.c (contents, props changed) head/sys/mips/conf/GXEMUL (contents, props changed) head/sys/mips/conf/GXEMUL.hints (contents, props changed) head/sys/mips/gxemul/ head/sys/mips/gxemul/files.gxemul (contents, props changed) head/sys/mips/gxemul/gxemul_machdep.c (contents, props changed) head/sys/mips/gxemul/std.gxemul (contents, props changed) Added: head/sys/dev/gxemul/cons/gxemul_cons.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/gxemul/cons/gxemul_cons.c Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,334 @@ +/*- + * Copyright (c) 2011-2012 Robert N. M. Watson + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define GC_LOCK_INIT() mtx_init(&gc_lock, "gc_lock", NULL, MTX_SPIN) + +#define GC_LOCK() do { \ + if (!kdb_active) \ + mtx_lock_spin(&gc_lock); \ +} while (0) + +#define GC_LOCK_ASSERT() do { \ + if (!kdb_active) \ + mtx_assert(&gc_lock, MA_OWNED); \ +} while (0) + +#define GC_UNLOCK() do { \ + if (!kdb_active) \ + mtx_unlock_spin(&gc_lock); \ +} while (0) + + +static struct mtx gc_lock; + +/* + * Low-level console driver functions. + */ +static cn_probe_t gxemul_cons_cnprobe; +static cn_init_t gxemul_cons_cninit; +static cn_term_t gxemul_cons_cnterm; +static cn_getc_t gxemul_cons_cngetc; +static cn_putc_t gxemul_cons_cnputc; +static cn_grab_t gxemul_cons_cngrab; +static cn_ungrab_t gxemul_cons_cnungrab; + +/* + * TTY-level fields. + */ +static tsw_outwakeup_t gxemul_cons_outwakeup; + +static struct ttydevsw gxemul_cons_ttydevsw = { + .tsw_flags = TF_NOPREFIX, + .tsw_outwakeup = gxemul_cons_outwakeup, +}; + +static struct callout gxemul_cons_callout; +static u_int gxemul_cons_polltime = 10; +#ifdef KDB +static int gxemul_cons_alt_break_state; +#endif + +static void gxemul_cons_timeout(void *); + +/* + * I/O routines lifted from Deimos. + * + * XXXRW: Should be using FreeBSD's bus routines here, but they are not + * available until later in the boot. + */ +#define MIPS_XKPHYS_UNCACHED_BASE 0x9000000000000000 + +typedef uint64_t paddr_t; +typedef uint64_t vaddr_t; + +static inline vaddr_t +mips_phys_to_uncached(paddr_t phys) +{ + + return (phys | MIPS_XKPHYS_UNCACHED_BASE); +} + +static inline uint8_t +mips_ioread_uint8(vaddr_t vaddr) +{ + uint8_t v; + + __asm__ __volatile__ ("lbu %0, 0(%1)" : "=r" (v) : "r" (vaddr)); + return (v); +} + +static inline void +mips_iowrite_uint8(vaddr_t vaddr, uint8_t v) +{ + + __asm__ __volatile__ ("sb %0, 0(%1)" : : "r" (v), "r" (vaddr)); +} + +/* + * gxemul-specific constants. + */ +#define GXEMUL_CONS_BASE 0x10000000 /* gxemul console device. */ + +/* + * Routines for interacting with the gxemul test console. Programming details + * are a result of manually inspecting the source code for gxemul's + * dev_cons.cc and dev_cons.h. + * + * Offsets of I/O channels relative to the base. + */ +#define GXEMUL_PUTGETCHAR_OFF 0x00000000 +#define GXEMUL_CONS_HALT 0x00000010 + +/* + * One-byte buffer as we can't check whether the console is readable without + * actually reading from it. + */ +static char buffer_data; +static int buffer_valid; + +/* + * Low-level read and write routines. + */ +static inline uint8_t +gxemul_cons_data_read(void) +{ + + return (mips_ioread_uint8(mips_phys_to_uncached(GXEMUL_CONS_BASE + + GXEMUL_PUTGETCHAR_OFF))); +} + +static inline void +gxemul_cons_data_write(uint8_t v) +{ + + mips_iowrite_uint8(mips_phys_to_uncached(GXEMUL_CONS_BASE + + GXEMUL_PUTGETCHAR_OFF), v); +} + +static int +gxemul_cons_writable(void) +{ + + return (1); +} + +static int +gxemul_cons_readable(void) +{ + uint32_t v; + + GC_LOCK_ASSERT(); + + if (buffer_valid) + return (1); + v = gxemul_cons_data_read(); + if (v != 0) { + buffer_valid = 1; + buffer_data = v; + return (1); + } + return (0); +} + +static void +gxemul_cons_write(char ch) +{ + + GC_LOCK_ASSERT(); + + while (!gxemul_cons_writable()); + gxemul_cons_data_write(ch); +} + +static char +gxemul_cons_read(void) +{ + + GC_LOCK_ASSERT(); + + while (!gxemul_cons_readable()); + buffer_valid = 0; + return (buffer_data); +} + +/* + * Implementation of a FreeBSD low-level, polled console driver. + */ +static void +gxemul_cons_cnprobe(struct consdev *cp) +{ + + sprintf(cp->cn_name, "gxcons"); + cp->cn_pri = CN_NORMAL; +} + +static void +gxemul_cons_cninit(struct consdev *cp) +{ + + GC_LOCK_INIT(); +} + +static void +gxemul_cons_cnterm(struct consdev *cp) +{ + +} + +static int +gxemul_cons_cngetc(struct consdev *cp) +{ + int ret; + + GC_LOCK(); + ret = gxemul_cons_read(); + GC_UNLOCK(); + return (ret); +} + +static void +gxemul_cons_cnputc(struct consdev *cp, int c) +{ + + GC_LOCK(); + gxemul_cons_write(c); + GC_UNLOCK(); +} + +static void +gxemul_cons_cngrab(struct consdev *cp) +{ + +} + +static void +gxemul_cons_cnungrab(struct consdev *cp) +{ + +} + +CONSOLE_DRIVER(gxemul_cons); + +/* + * TTY-level functions for gxemul_cons. + */ +static void +gxemul_cons_ttyinit(void *unused) +{ + struct tty *tp; + + tp = tty_alloc(&gxemul_cons_ttydevsw, NULL); + tty_init_console(tp, 0); + tty_makedev(tp, NULL, "%s", "gxcons"); + callout_init(&gxemul_cons_callout, CALLOUT_MPSAFE); + callout_reset(&gxemul_cons_callout, gxemul_cons_polltime, + gxemul_cons_timeout, tp); + +} +SYSINIT(gxemul_cons_ttyinit, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, + gxemul_cons_ttyinit, NULL); + +static void +gxemul_cons_outwakeup(struct tty *tp) +{ + int len; + u_char ch; + + /* + * XXXRW: Would be nice not to do blocking writes to the console here, + * rescheduling on our timer tick if work remains to be done.. + */ + for (;;) { + len = ttydisc_getc(tp, &ch, sizeof(ch)); + if (len == 0) + break; + GC_LOCK(); + gxemul_cons_write(ch); + GC_UNLOCK(); + } +} + +static void +gxemul_cons_timeout(void *v) +{ + struct tty *tp; + int c; + + tp = v; + tty_lock(tp); + GC_LOCK(); + while (gxemul_cons_readable()) { + c = gxemul_cons_read(); + GC_UNLOCK(); +#ifdef KDB + kdb_alt_break(c, &gxemul_cons_alt_break_state); +#endif + ttydisc_rint(tp, c, 0); + GC_LOCK(); + } + GC_UNLOCK(); + ttydisc_rint_done(tp); + tty_unlock(tp); + callout_reset(&gxemul_cons_callout, gxemul_cons_polltime, + gxemul_cons_timeout, tp); +} Added: head/sys/mips/conf/GXEMUL ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/conf/GXEMUL Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,52 @@ +# +# GXEMUL "oldtestmips" sample kernel configuration. +# +# $FreeBSD$ +# + +ident GXEMUL + +machine mips mips64eb +cpu CPU_MIPS4KC + +options HZ=100 + +makeoptions ARCH_FLAGS="-march=mips64 -mabi=64" + +makeoptions KERNLOADADDR=0xffffffff80100000 + +include "../gxemul/std.gxemul" + +hints "GXEMUL.hints" #Default places to look for devices. + +makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols + +makeoptions MODULES_OVERRIDE="" + +options DDB +options KDB + +options SCHED_ULE + +options FFS #Berkeley Fast Filesystem + +# Debugging for use in -current +#options DEADLKRES #Enable the deadlock resolver +options INVARIANTS #Enable calls of extra sanity checking +options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS +#options WITNESS #Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed + +# +# This kernel configuration uses an embedded 8MB memory root file system. +# Adjust the following path based on local requirements. +# +options MD_ROOT # MD is a potential root device +options MD_ROOT_SIZE=8192 +#makeoptions MFS_IMAGE=/local/scratch/rnw24/mdroot.img +options ROOTDEVNAME=\"ufs:md0\" + +device gxemul_cons +device md +device loop +device random Added: head/sys/mips/conf/GXEMUL.hints ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/conf/GXEMUL.hints Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1 @@ +# $FreeBSD$ Added: head/sys/mips/gxemul/files.gxemul ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/gxemul/files.gxemul Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,5 @@ +# $FreeBSD$ +dev/gxemul/cons/gxemul_cons.c optional gxemul_cons +mips/gxemul/gxemul_machdep.c standard +mips/mips/intr_machdep.c standard +mips/mips/tick.c standard Added: head/sys/mips/gxemul/gxemul_machdep.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/gxemul/gxemul_machdep.c Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,191 @@ +/*- + * Copyright (c) 2006 Wojciech A. Koszek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS 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. + */ +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ddb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +extern int *edata; +extern int *end; + +void +platform_cpu_init() +{ + /* Nothing special */ +} + +static void +mips_init(void) +{ + int i; + + for (i = 0; i < 10; i++) { + phys_avail[i] = 0; + } + + /* phys_avail regions are in bytes */ + phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); + phys_avail[1] = ctob(realmem); + + dump_avail[0] = phys_avail[0]; + dump_avail[1] = phys_avail[1]; + + physmem = realmem; + + init_param1(); + init_param2(physmem); + mips_cpu_init(); + pmap_bootstrap(); + mips_proc0_init(); + mutex_init(); + kdb_init(); +#ifdef KDB + if (boothowto & RB_KDB) + kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); +#endif +} + +void +platform_halt(void) +{ + +} + + +void +platform_identify(void) +{ + +} + +/* + * Perform a board-level soft-reset. + * + * XXXRW: Does gxemul have a moral equivalent to board-level reset? + */ +void +platform_reset(void) +{ + + panic("%s: not yet", __func__); +} + +void +platform_trap_enter(void) +{ + +} + +void +platform_trap_exit(void) +{ + +} + +void +platform_start(__register_t a0, __register_t a1, __register_t a2, + __register_t a3) +{ + vm_offset_t kernend; + uint64_t platform_counter_freq; + int argc = a0; + char **argv = (char **)a1; + char **envp = (char **)a2; + unsigned int memsize = a3; + int i; + + /* clear the BSS and SBSS segments */ + kernend = (vm_offset_t)&end; + memset(&edata, 0, kernend - (vm_offset_t)(&edata)); + + mips_postboot_fixup(); + + mips_pcpu0_init(); + + /* + * XXXRW: Support for the gxemul real-time clock required in order to + * usefully determine our emulated timer frequency. Go with something + * classic as the default in the mean time. + */ + platform_counter_freq = MIPS_DEFAULT_HZ; + mips_timer_early_init(platform_counter_freq); + + cninit(); + printf("entry: platform_start()\n"); + + bootverbose = 1; + if (bootverbose) { + printf("cmd line: "); + for (i = 0; i < argc; i++) + printf("%s ", argv[i]); + printf("\n"); + + printf("envp:\n"); + for (i = 0; envp[i]; i += 2) + printf("\t%s = %s\n", envp[i], envp[i+1]); + + printf("memsize = %08x\n", memsize); + } + + realmem = btoc(memsize); + mips_init(); + + mips_timer_init_params(platform_counter_freq, 0); +} Added: head/sys/mips/gxemul/std.gxemul ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/gxemul/std.gxemul Wed May 2 08:10:15 2012 (r234920) @@ -0,0 +1,4 @@ +# $FreeBSD$ +files "../gxemul/files.gxemul" + +cpu CPU_MIPS4KC From owner-svn-src-head@FreeBSD.ORG Wed May 2 08:23:53 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AD149106564A; Wed, 2 May 2012 08:23:53 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 978818FC12; Wed, 2 May 2012 08:23:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q428Nrd9073556; Wed, 2 May 2012 08:23:53 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q428Nrbe073554; Wed, 2 May 2012 08:23:53 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201205020823.q428Nrbe073554@svn.freebsd.org> From: Robert Watson Date: Wed, 2 May 2012 08:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234921 - head/sys/mips/mips X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 08:23:53 -0000 Author: rwatson Date: Wed May 2 08:23:53 2012 New Revision: 234921 URL: http://svn.freebsd.org/changeset/base/234921 Log: Clean up various aspects of the MIPS generic busspace implementation: 1) Always implement missing bus space methods using a panic() stub rather than a NULL pointer. This appeared not to trip up any existing device drivers, but due to the nature of the devices I'm supporting locally, I'm making use of some of the more obscure busspace methods, and panic() is a preferred failure mode. For example, do this for the setregion methods. 2) Hook up several existing busspace method implementations that were provided in the file, but not actually present in the methods structure. Especially, single-byte bus I/O routines. This should allow bugs to be fixed in the Atheros 802.11 driver. There are still some remaining unimplemented methods that would be desirable to implement -- especially, 64-bit I/O calls that would observably accelerate device performance on FPGA-based soft CPU cores that are typically clocked an order of magnitude slower than conventional hard core CPUs, but that remains for another day. MFC after: 3 weeks Discussed with: jmallett, scottl Sponsored by: DARPA, AFRL Modified: head/sys/mips/mips/bus_space_generic.c Modified: head/sys/mips/mips/bus_space_generic.c ============================================================================== --- head/sys/mips/mips/bus_space_generic.c Wed May 2 08:10:15 2012 (r234920) +++ head/sys/mips/mips/bus_space_generic.c Wed May 2 08:23:53 2012 (r234921) @@ -99,8 +99,8 @@ static struct bus_space generic_space = generic_bs_subregion, /* allocation/deallocation */ - NULL, - NULL, + generic_bs_alloc, + generic_bs_free, /* barrier */ generic_bs_barrier, @@ -109,91 +109,91 @@ static struct bus_space generic_space = generic_bs_r_1, generic_bs_r_2, generic_bs_r_4, - NULL, + generic_bs_r_8, /* read multiple */ generic_bs_rm_1, generic_bs_rm_2, generic_bs_rm_4, - NULL, + generic_bs_rm_8, /* read region */ generic_bs_rr_1, generic_bs_rr_2, generic_bs_rr_4, - NULL, + generic_bs_rr_8, /* write (single) */ generic_bs_w_1, generic_bs_w_2, generic_bs_w_4, - NULL, + generic_bs_w_8, /* write multiple */ generic_bs_wm_1, generic_bs_wm_2, generic_bs_wm_4, - NULL, + generic_bs_wm_8, /* write region */ - NULL, + generic_bs_wr_1, generic_bs_wr_2, generic_bs_wr_4, - NULL, + generic_bs_wr_8, /* set multiple */ - NULL, - NULL, - NULL, - NULL, + generic_bs_sm_1, + generic_bs_sm_2, + generic_bs_sm_4, + generic_bs_sm_8, /* set region */ - NULL, + generic_bs_sr_1, generic_bs_sr_2, generic_bs_sr_4, - NULL, + generic_bs_sr_8, /* copy */ - NULL, + generic_bs_c_1, generic_bs_c_2, - NULL, - NULL, + generic_bs_c_4, + generic_bs_c_8, /* read (single) stream */ generic_bs_r_1, generic_bs_r_2, generic_bs_r_4, - NULL, + generic_bs_r_8, /* read multiple stream */ generic_bs_rm_1, generic_bs_rm_2, generic_bs_rm_4, - NULL, + generic_bs_rm_8, /* read region stream */ generic_bs_rr_1, generic_bs_rr_2, generic_bs_rr_4, - NULL, + generic_bs_rr_8, /* write (single) stream */ generic_bs_w_1, generic_bs_w_2, generic_bs_w_4, - NULL, + generic_bs_w_8, /* write multiple stream */ generic_bs_wm_1, generic_bs_wm_2, generic_bs_wm_4, - NULL, + generic_bs_wm_8, /* write region stream */ - NULL, + generic_bs_wr_1, generic_bs_wr_2, generic_bs_wr_4, - NULL, + generic_bs_wr_8, }; /* Ultra-gross kludge */ @@ -253,6 +253,22 @@ generic_bs_subregion(void *t __unused, b return (0); } +int +generic_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, + bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags, + bus_addr_t *bpap, bus_space_handle_t *bshp) +{ + + panic("%s: not implemented", __func__); +} + +void +generic_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) +{ + + panic("%s: not implemented", __func__); +} + uint8_t generic_bs_r_1(void *t, bus_space_handle_t handle, bus_size_t offset) @@ -277,6 +293,12 @@ generic_bs_r_4(void *t, bus_space_handle return (rd32(handle + offset)); } +uint64_t +generic_bs_r_8(void *t, bus_space_handle_t handle, bus_size_t offset) +{ + + panic("%s: not implemented", __func__); +} void generic_bs_rm_1(void *t, bus_space_handle_t bsh, @@ -307,6 +329,13 @@ generic_bs_rm_4(void *t, bus_space_handl *addr++ = rd32(baddr); } +void +generic_bs_rm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} /* * Read `count' 1, 2, 4, or 8 byte quantities from bus space @@ -349,6 +378,14 @@ generic_bs_rr_4(void *t, bus_space_handl } } +void +generic_bs_rr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write the 1, 2, 4, or 8 byte value `value' to bus space * described by tag/handle/offset. @@ -377,6 +414,14 @@ generic_bs_w_4(void *t, bus_space_handle wr32(bsh + offset, value); } +void +generic_bs_w_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t value) +{ + + panic("%s: not implemented", __func__); +} + /* * Write `count' 1, 2, 4, or 8 byte quantities from the buffer * provided to bus space described by tag/handle/offset. @@ -411,6 +456,14 @@ generic_bs_wm_4(void *t, bus_space_handl wr32(baddr, *addr++); } +void +generic_bs_wm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + const uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided * to bus space described by tag/handle starting at `offset'. @@ -451,6 +504,14 @@ generic_bs_wr_4(void *t, bus_space_handl } } +void +generic_bs_wr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + const uint64_t *addr, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write the 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle/offset `count' times. @@ -485,6 +546,14 @@ generic_bs_sm_4(void *t, bus_space_handl wr32(addr, value); } +void +generic_bs_sm_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t value, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described * by tag/handle starting at `offset'. @@ -519,6 +588,14 @@ generic_bs_sr_4(void *t, bus_space_handl wr32(addr, value); } +void +generic_bs_sr_8(void *t, bus_space_handle_t bsh, bus_size_t offset, + uint64_t value, size_t count) +{ + + panic("%s: not implemented", __func__); +} + /* * Copy `count' 1, 2, 4, or 8 byte values from bus space starting * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. @@ -584,6 +661,14 @@ generic_bs_c_4(void *t, bus_space_handle } void +generic_bs_c_8(void *t, bus_space_handle_t bsh1, bus_size_t off1, + bus_space_handle_t bsh2, bus_size_t off2, size_t count) +{ + + panic("%s: not implemented", __func__); +} + +void generic_bs_barrier(void *t __unused, bus_space_handle_t bsh __unused, bus_size_t offset __unused, bus_size_t len __unused, From owner-svn-src-head@FreeBSD.ORG Wed May 2 09:19:43 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4F481106564A; Wed, 2 May 2012 09:19:43 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3AC538FC08; Wed, 2 May 2012 09:19:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q429Jhml075613; Wed, 2 May 2012 09:19:43 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q429Jhbm075611; Wed, 2 May 2012 09:19:43 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205020919.q429Jhbm075611@svn.freebsd.org> From: Warner Losh Date: Wed, 2 May 2012 09:19:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234923 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 09:19:43 -0000 Author: imp Date: Wed May 2 09:19:42 2012 New Revision: 234923 URL: http://svn.freebsd.org/changeset/base/234923 Log: The PIT is really 16 bytes long (0x10) not 10 bytes long. Doesn't matter much, since these defines are unused... Obtained from: AT91SAM9G20 datasheet Modified: head/sys/arm/at91/at91sam9g20reg.h Modified: head/sys/arm/at91/at91sam9g20reg.h ============================================================================== --- head/sys/arm/at91/at91sam9g20reg.h Wed May 2 08:38:43 2012 (r234922) +++ head/sys/arm/at91/at91sam9g20reg.h Wed May 2 09:19:42 2012 (r234923) @@ -238,7 +238,7 @@ #define AT91SAM9G20_WDT_SIZE 0x10 #define AT91SAM9G20_PIT_BASE 0xffffd30 -#define AT91SAM9G20_PIT_SIZE 10 +#define AT91SAM9G20_PIT_SIZE 0x10 #define AT91SAM9G20_SMC_BASE 0xfffec00 #define AT91SAM9G20_SMC_SIZE 0x200 From owner-svn-src-head@FreeBSD.ORG Wed May 2 10:15:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC460106566B; Wed, 2 May 2012 10:15:42 +0000 (UTC) (envelope-from jasone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 97E048FC16; Wed, 2 May 2012 10:15:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42AFgdS077688; Wed, 2 May 2012 10:15:42 GMT (envelope-from jasone@svn.freebsd.org) Received: (from jasone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42AFgrf077686; Wed, 2 May 2012 10:15:42 GMT (envelope-from jasone@svn.freebsd.org) Message-Id: <201205021015.q42AFgrf077686@svn.freebsd.org> From: Jason Evans Date: Wed, 2 May 2012 10:15:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234924 - head/sys/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 10:15:42 -0000 Author: jasone Date: Wed May 2 10:15:42 2012 New Revision: 234924 URL: http://svn.freebsd.org/changeset/base/234924 Log: Bump __FreeBSD_version due to jemalloc import. Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Wed May 2 09:19:42 2012 (r234923) +++ head/sys/sys/param.h Wed May 2 10:15:42 2012 (r234924) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1000011 /* Master, propagated to newvers */ +#define __FreeBSD_version 1000012 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-head@FreeBSD.ORG Wed May 2 12:15:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 621361065678; Wed, 2 May 2012 12:15:35 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4CCC98FC08; Wed, 2 May 2012 12:15:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42CFZod084339; Wed, 2 May 2012 12:15:35 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42CFZo9084337; Wed, 2 May 2012 12:15:35 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201205021215.q42CFZo9084337@svn.freebsd.org> From: Robert Watson Date: Wed, 2 May 2012 12:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234926 - head/sys/mips/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 12:15:35 -0000 Author: rwatson Date: Wed May 2 12:15:34 2012 New Revision: 234926 URL: http://svn.freebsd.org/changeset/base/234926 Log: mips/mips64eb became mips/mips64 while I wasn't looking (whoops), so update GXEMUL kernel config for the new world order. Spotted by: bz MFC after: 3 weeks Modified: head/sys/mips/conf/GXEMUL Modified: head/sys/mips/conf/GXEMUL ============================================================================== --- head/sys/mips/conf/GXEMUL Wed May 2 11:38:58 2012 (r234925) +++ head/sys/mips/conf/GXEMUL Wed May 2 12:15:34 2012 (r234926) @@ -6,7 +6,7 @@ ident GXEMUL -machine mips mips64eb +machine mips mips64 cpu CPU_MIPS4KC options HZ=100 From owner-svn-src-head@FreeBSD.ORG Wed May 2 14:25:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D141D106564A; Wed, 2 May 2012 14:25:39 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BBA5B8FC0A; Wed, 2 May 2012 14:25:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42EPdUF088860; Wed, 2 May 2012 14:25:39 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42EPdqw088857; Wed, 2 May 2012 14:25:39 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201205021425.q42EPdqw088857@svn.freebsd.org> From: John Baldwin Date: Wed, 2 May 2012 14:25:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234927 - in head: etc/rc.d sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 14:25:40 -0000 Author: jhb Date: Wed May 2 14:25:39 2012 New Revision: 234927 URL: http://svn.freebsd.org/changeset/base/234927 Log: - Don't log messages saying that accounting is being disabled and enabled if the accounting log file is atomically replaced with a new file (such as during log rotation). - Simplify accounting log rotation a bit. There is no need to re-run accton(8) after renaming the new log file to it's real name. PR: kern/167321 Tested by: Jeremy Chadwick Modified: head/etc/rc.d/accounting head/sys/kern/kern_acct.c Modified: head/etc/rc.d/accounting ============================================================================== --- head/etc/rc.d/accounting Wed May 2 12:15:34 2012 (r234926) +++ head/etc/rc.d/accounting Wed May 2 14:25:39 2012 (r234927) @@ -65,9 +65,7 @@ accounting_rotate_log() mv ${accounting_file} ${accounting_file}.0 if checkyesno accounting_enable; then - ln $_file ${accounting_file##*/} - ${accounting_command} ${accounting_file} - unlink $_file + mv $_file ${accounting_file} fi } Modified: head/sys/kern/kern_acct.c ============================================================================== --- head/sys/kern/kern_acct.c Wed May 2 12:15:34 2012 (r234926) +++ head/sys/kern/kern_acct.c Wed May 2 14:25:39 2012 (r234927) @@ -122,7 +122,7 @@ static uint32_t encode_timeval(struct ti static uint32_t encode_long(long); static void acctwatch(void); static void acct_thread(void *); -static int acct_disable(struct thread *); +static int acct_disable(struct thread *, int); /* * Accounting vnode pointer, saved vnode pointer, and flags for each. @@ -196,7 +196,7 @@ int sys_acct(struct thread *td, struct acct_args *uap) { struct nameidata nd; - int error, flags, vfslocked; + int error, flags, vfslocked, replacing; error = priv_check(td, PRIV_ACCT); if (error) @@ -246,6 +246,13 @@ sys_acct(struct thread *td, struct acct_ sx_xlock(&acct_sx); /* + * Don't log spurious disable/enable messages if we are + * switching from one accounting file to another due to log + * rotation. + */ + replacing = (acct_vp != NULL && uap->path != NULL); + + /* * If accounting was previously enabled, kill the old space-watcher, * close the file, and (if no new file was specified, leave). Reset * the suspended state regardless of whether accounting remains @@ -254,7 +261,7 @@ sys_acct(struct thread *td, struct acct_ acct_suspended = 0; if (acct_vp != NULL) { vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); - error = acct_disable(td); + error = acct_disable(td, !replacing); VFS_UNLOCK_GIANT(vfslocked); } if (uap->path == NULL) { @@ -299,7 +306,8 @@ sys_acct(struct thread *td, struct acct_ } acct_configured = 1; sx_xunlock(&acct_sx); - log(LOG_NOTICE, "Accounting enabled\n"); + if (!replacing) + log(LOG_NOTICE, "Accounting enabled\n"); return (error); } @@ -308,7 +316,7 @@ sys_acct(struct thread *td, struct acct_ * our reference to the credential, and clearing the vnode's flags. */ static int -acct_disable(struct thread *td) +acct_disable(struct thread *td, int logging) { int error; @@ -319,7 +327,8 @@ acct_disable(struct thread *td) acct_vp = NULL; acct_cred = NULL; acct_flags = 0; - log(LOG_NOTICE, "Accounting disabled\n"); + if (logging) + log(LOG_NOTICE, "Accounting disabled\n"); return (error); } @@ -574,7 +583,7 @@ acctwatch(void) */ vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount); if (acct_vp->v_type == VBAD) { - (void) acct_disable(NULL); + (void) acct_disable(NULL, 1); VFS_UNLOCK_GIANT(vfslocked); acct_state |= ACCT_EXITREQ; return; From owner-svn-src-head@FreeBSD.ORG Wed May 2 14:38:43 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9A32106564A; Wed, 2 May 2012 14:38:43 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4CFC8FC08; Wed, 2 May 2012 14:38:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42Ech54089330; Wed, 2 May 2012 14:38:43 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42Echhn089328; Wed, 2 May 2012 14:38:43 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205021438.q42Echhn089328@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 2 May 2012 14:38:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234928 - head/sys/mips/gxemul X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 14:38:44 -0000 Author: bz Date: Wed May 2 14:38:43 2012 New Revision: 234928 URL: http://svn.freebsd.org/changeset/base/234928 Log: Catch-up with r232853 and remove platform APIs which are not used by any code and which had only stub implementations or no implementation on all platforms. Makes gxemul compile. Hinted by: rwatson MFC after: 3 weeks X-MFC by: rwatson: Modified: head/sys/mips/gxemul/gxemul_machdep.c Modified: head/sys/mips/gxemul/gxemul_machdep.c ============================================================================== --- head/sys/mips/gxemul/gxemul_machdep.c Wed May 2 14:25:39 2012 (r234927) +++ head/sys/mips/gxemul/gxemul_machdep.c Wed May 2 14:38:43 2012 (r234928) @@ -102,19 +102,6 @@ mips_init(void) #endif } -void -platform_halt(void) -{ - -} - - -void -platform_identify(void) -{ - -} - /* * Perform a board-level soft-reset. * @@ -128,18 +115,6 @@ platform_reset(void) } void -platform_trap_enter(void) -{ - -} - -void -platform_trap_exit(void) -{ - -} - -void platform_start(__register_t a0, __register_t a1, __register_t a2, __register_t a3) { From owner-svn-src-head@FreeBSD.ORG Wed May 2 16:23:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 549F01065670; Wed, 2 May 2012 16:23:37 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3EF3E8FC15; Wed, 2 May 2012 16:23:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42GNbJV093084; Wed, 2 May 2012 16:23:37 GMT (envelope-from gnn@svn.freebsd.org) Received: (from gnn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42GNbGe093082; Wed, 2 May 2012 16:23:37 GMT (envelope-from gnn@svn.freebsd.org) Message-Id: <201205021623.q42GNbGe093082@svn.freebsd.org> From: "George V. Neville-Neil" Date: Wed, 2 May 2012 16:23:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234930 - head/sys/dev/hwpmc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 16:23:37 -0000 Author: gnn Date: Wed May 2 16:23:36 2012 New Revision: 234930 URL: http://svn.freebsd.org/changeset/base/234930 Log: Fix so that ,usr and ,os work correctly with fixed function (IAF) counters. MFC after: 1 week Modified: head/sys/dev/hwpmc/hwpmc_core.c Modified: head/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_core.c Wed May 2 15:15:28 2012 (r234929) +++ head/sys/dev/hwpmc/hwpmc_core.c Wed May 2 16:23:36 2012 (r234930) @@ -52,7 +52,8 @@ __FBSDID("$FreeBSD$"); #define CORE_CPUID_EDX 0x3 #define IAF_PMC_CAPS \ - (PMC_CAP_READ | PMC_CAP_WRITE | PMC_CAP_INTERRUPT) + (PMC_CAP_READ | PMC_CAP_WRITE | PMC_CAP_INTERRUPT | \ + PMC_CAP_USER | PMC_CAP_SYSTEM) #define IAF_RI_TO_MSR(RI) ((RI) + (1 << 30)) #define IAP_PMC_CAPS (PMC_CAP_INTERRUPT | PMC_CAP_USER | PMC_CAP_SYSTEM | \ From owner-svn-src-head@FreeBSD.ORG Wed May 2 18:41:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1FFE4106566B; Wed, 2 May 2012 18:41:59 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B5098FC0A; Wed, 2 May 2012 18:41:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42IfwDK097961; Wed, 2 May 2012 18:41:58 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42IfwCY097959; Wed, 2 May 2012 18:41:58 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205021841.q42IfwCY097959@svn.freebsd.org> From: Warner Losh Date: Wed, 2 May 2012 18:41:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234931 - head/sys/arm/at91 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 18:41:59 -0000 Author: imp Date: Wed May 2 18:41:58 2012 New Revision: 234931 URL: http://svn.freebsd.org/changeset/base/234931 Log: Fix comment about what board this is really for left over from early cut and paste. Modified: head/sys/arm/at91/board_sam9g20ek.c Modified: head/sys/arm/at91/board_sam9g20ek.c ============================================================================== --- head/sys/arm/at91/board_sam9g20ek.c Wed May 2 16:23:36 2012 (r234930) +++ head/sys/arm/at91/board_sam9g20ek.c Wed May 2 18:41:58 2012 (r234931) @@ -25,11 +25,7 @@ /* * This board file can be used for both: - * Atmel AT91SAM9260-B Development Card and - * Atmel AT91SAM9G20-EK Rev. B Development Card - * - * Since the AT91SAM9260 and AT91SAM9G20 have identical memory maps and - * pin configurations we can use the same file for both. + * Atmel SAM9G20-EK Development Card */ #include From owner-svn-src-head@FreeBSD.ORG Wed May 2 19:25:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id 0616E106564A; Wed, 2 May 2012 19:25:15 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from [127.0.0.1] (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id 8BE3815049E; Wed, 2 May 2012 19:25:14 +0000 (UTC) Message-ID: <4FA18A1B.30203@FreeBSD.org> Date: Wed, 02 May 2012 12:25:15 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: John Baldwin References: <201205021425.q42EPdqw088857@svn.freebsd.org> In-Reply-To: <201205021425.q42EPdqw088857@svn.freebsd.org> X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234927 - in head: etc/rc.d sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 19:25:15 -0000 On 5/2/2012 7:25 AM, John Baldwin wrote: > - Simplify accounting log rotation a bit. There is no need to re-run > accton(8) after renaming the new log file to it's real name. Have you thoroughly tested this change? I remember adding that on purpose, but I couldn't tell you for sure at this point exactly why. -- This .signature sanitized for your protection From owner-svn-src-head@FreeBSD.ORG Wed May 2 19:32:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA4831065674; Wed, 2 May 2012 19:32:11 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 94EF88FC1C; Wed, 2 May 2012 19:32:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42JWBZ8099731; Wed, 2 May 2012 19:32:11 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42JWBMs099729; Wed, 2 May 2012 19:32:11 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201205021932.q42JWBMs099729@svn.freebsd.org> From: Peter Holm Date: Wed, 2 May 2012 19:32:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234932 - head/sys/dev/sound/pcm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 19:32:11 -0000 Author: pho Date: Wed May 2 19:32:11 2012 New Revision: 234932 URL: http://svn.freebsd.org/changeset/base/234932 Log: Added D_TRACKCLOSE to sndstat_cdevsw to fix the situation when another process is in open() or stat() for the device node, then close() from the owning process does not result in cdevsw close method call. This fixes the pemanent "Device busy" seen. Changed the sndstat_lock from mutex to sx. This allows to extend the region covered by the lock, to include the uiomove() call in sndstat_read() and bufptr increment. This fixes the "panic: sbuf_put_byte called with finished or corrupt sbuf" seen. In collaboration with: kib MFC after: 1 week Modified: head/sys/dev/sound/pcm/sndstat.c Modified: head/sys/dev/sound/pcm/sndstat.c ============================================================================== --- head/sys/dev/sound/pcm/sndstat.c Wed May 2 18:41:58 2012 (r234931) +++ head/sys/dev/sound/pcm/sndstat.c Wed May 2 19:32:11 2012 (r234932) @@ -53,6 +53,7 @@ static struct cdevsw sndstat_cdevsw = { .d_close = sndstat_close, .d_read = sndstat_read, .d_name = "sndstat", + .d_flags = D_TRACKCLOSE, }; struct sndstat_entry { @@ -63,7 +64,7 @@ struct sndstat_entry { int type, unit; }; -static struct mtx sndstat_lock; +static struct sx sndstat_lock; static struct sbuf sndstat_sbuf; static struct cdev *sndstat_dev = NULL; static int sndstat_bufptr = -1; @@ -93,16 +94,14 @@ sysctl_hw_snd_sndstat_pid(SYSCTL_HANDLER if (sndstat_dev == NULL) return (EINVAL); - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); val = (int)SNDSTAT_PID(sndstat_dev); - mtx_unlock(&sndstat_lock); err = sysctl_handle_int(oidp, &val, 0, req); if (err == 0 && req->newptr != NULL && val == 0) { - mtx_lock(&sndstat_lock); SNDSTAT_FLUSH(); SNDSTAT_PID_SET(sndstat_dev, 0); - mtx_unlock(&sndstat_lock); } + sx_unlock(&sndstat_lock); return (err); } SYSCTL_PROC(_hw_snd, OID_AUTO, sndstat_pid, CTLTYPE_INT | CTLFLAG_RW, @@ -119,12 +118,10 @@ sysctl_hw_sndverbose(SYSCTL_HANDLER_ARGS verbose = snd_verbose; error = sysctl_handle_int(oidp, &verbose, 0, req); if (error == 0 && req->newptr != NULL) { - mtx_lock(&sndstat_lock); if (verbose < 0 || verbose > 4) error = EINVAL; else snd_verbose = verbose; - mtx_unlock(&sndstat_lock); } return error; } @@ -137,20 +134,19 @@ sndstat_open(struct cdev *i_dev, int fla if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(i_dev) != 0) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBUSY; } SNDSTAT_PID_SET(i_dev, td->td_proc->p_pid); - mtx_unlock(&sndstat_lock); if (sbuf_new(&sndstat_sbuf, NULL, 4096, SBUF_AUTOEXTEND) == NULL) { - mtx_lock(&sndstat_lock); SNDSTAT_PID_SET(i_dev, 0); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return ENXIO; } sndstat_bufptr = 0; + sx_unlock(&sndstat_lock); return 0; } @@ -160,16 +156,16 @@ sndstat_close(struct cdev *i_dev, int fl if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(i_dev) == 0) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBADF; } SNDSTAT_FLUSH(); SNDSTAT_PID_SET(i_dev, 0); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -182,20 +178,18 @@ sndstat_read(struct cdev *i_dev, struct if (sndstat_dev == NULL || i_dev != sndstat_dev) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(i_dev) != buf->uio_td->td_proc->p_pid || sndstat_bufptr == -1) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBADF; } - mtx_unlock(&sndstat_lock); if (sndstat_bufptr == 0) { err = (sndstat_prepare(&sndstat_sbuf) > 0) ? 0 : ENOMEM; if (err) { - mtx_lock(&sndstat_lock); SNDSTAT_FLUSH(); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return err; } } @@ -203,6 +197,7 @@ sndstat_read(struct cdev *i_dev, struct l = min(buf->uio_resid, sbuf_len(&sndstat_sbuf) - sndstat_bufptr); err = (l > 0)? uiomove(sbuf_data(&sndstat_sbuf) + sndstat_bufptr, l, buf) : 0; sndstat_bufptr += l; + sx_unlock(&sndstat_lock); return err; } @@ -228,13 +223,13 @@ sndstat_acquire(struct thread *td) if (sndstat_dev == NULL) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(sndstat_dev) != 0) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBUSY; } SNDSTAT_PID_SET(sndstat_dev, td->td_proc->p_pid); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -244,13 +239,13 @@ sndstat_release(struct thread *td) if (sndstat_dev == NULL) return EBADF; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(sndstat_dev) != td->td_proc->p_pid) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBADF; } SNDSTAT_PID_SET(sndstat_dev, 0); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -284,12 +279,12 @@ sndstat_register(device_t dev, char *str ent->unit = unit; ent->handler = handler; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); SLIST_INSERT_HEAD(&sndstat_devlist, ent, link); if (type == SS_TYPE_MODULE) sndstat_files++; sndstat_maxunit = (unit > sndstat_maxunit)? unit : sndstat_maxunit; - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return 0; } @@ -305,17 +300,17 @@ sndstat_unregister(device_t dev) { struct sndstat_entry *ent; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); SLIST_FOREACH(ent, &sndstat_devlist, link) { if (ent->dev == dev) { SLIST_REMOVE(&sndstat_devlist, ent, sndstat_entry, link); - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); free(ent, M_DEVBUF); return 0; } } - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return ENXIO; } @@ -325,18 +320,18 @@ sndstat_unregisterfile(char *str) { struct sndstat_entry *ent; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); SLIST_FOREACH(ent, &sndstat_devlist, link) { if (ent->dev == NULL && ent->str == str) { SLIST_REMOVE(&sndstat_devlist, ent, sndstat_entry, link); sndstat_files--; - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); free(ent, M_DEVBUF); return 0; } } - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return ENXIO; } @@ -399,7 +394,7 @@ sndstat_init(void) { if (sndstat_dev != NULL) return EINVAL; - mtx_init(&sndstat_lock, "sndstat", "sndstat lock", MTX_DEF); + sx_init(&sndstat_lock, "sndstat lock"); sndstat_dev = make_dev(&sndstat_cdevsw, SND_DEV_STATUS, UID_ROOT, GID_WHEEL, 0444, "sndstat"); return 0; @@ -411,20 +406,20 @@ sndstat_uninit(void) if (sndstat_dev == NULL) return EINVAL; - mtx_lock(&sndstat_lock); + sx_xlock(&sndstat_lock); if (SNDSTAT_PID(sndstat_dev) != curthread->td_proc->p_pid) { - mtx_unlock(&sndstat_lock); + sx_unlock(&sndstat_lock); return EBUSY; } - SNDSTAT_FLUSH(); - - mtx_unlock(&sndstat_lock); - + /* XXXPHO: use destroy_dev_sched() */ destroy_dev(sndstat_dev); sndstat_dev = NULL; - mtx_destroy(&sndstat_lock); + SNDSTAT_FLUSH(); + + sx_unlock(&sndstat_lock); + sx_destroy(&sndstat_lock); return 0; } From owner-svn-src-head@FreeBSD.ORG Wed May 2 20:01:28 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA211106564A; Wed, 2 May 2012 20:01:28 +0000 (UTC) (envelope-from monthadar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D552C8FC08; Wed, 2 May 2012 20:01:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42K1S2j000909; Wed, 2 May 2012 20:01:28 GMT (envelope-from monthadar@svn.freebsd.org) Received: (from monthadar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42K1Shb000907; Wed, 2 May 2012 20:01:28 GMT (envelope-from monthadar@svn.freebsd.org) Message-Id: <201205022001.q42K1Shb000907@svn.freebsd.org> From: Monthadar Al Jaberi Date: Wed, 2 May 2012 20:01:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234933 - head/sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 20:01:29 -0000 Author: monthadar Date: Wed May 2 20:01:28 2012 New Revision: 234933 URL: http://svn.freebsd.org/changeset/base/234933 Log: Update man page date to the date of the last commit. Approved by: adrian Modified: head/sbin/ifconfig/ifconfig.8 Modified: head/sbin/ifconfig/ifconfig.8 ============================================================================== --- head/sbin/ifconfig/ifconfig.8 Wed May 2 19:32:11 2012 (r234932) +++ head/sbin/ifconfig/ifconfig.8 Wed May 2 20:01:28 2012 (r234933) @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd April 3, 2012 +.Dd May 1, 2012 .Dt IFCONFIG 8 .Os .Sh NAME From owner-svn-src-head@FreeBSD.ORG Wed May 2 20:04:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 171961065677; Wed, 2 May 2012 20:04:11 +0000 (UTC) (envelope-from monthadar@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 270898FC21; Wed, 2 May 2012 20:04:10 +0000 (UTC) Received: by weyt57 with SMTP id t57so888562wey.13 for ; Wed, 02 May 2012 13:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=8I1bBaSqUtQnIgE07xfjUm9KINAERnyNcy+Uts3kQ74=; b=hkEnHBWESPnrDXgba9SYxogoze9o9I+21LjeIqVgRc9jQdLnyQ4ufZdJmCdebHn8bf 5uXOJKOvjas9rxSF4tKBQMwKXqd5Z4ysot0FvwXz4/PgcTrGXjRTizrd8eJ4mJpSI1Aw 8+ixzZ+NulNHKUvwgVw4tnvBCRozraEV0aB7YFUKy/iIFr+eQssgtSpOq57YydPYFUX9 tZgt9pVkTIejPqPjpXAsBVLMf1WJr/SxDQ0D8rSGvXLGIGv12iMZdHCc36Lhi6pPlJFu am+iiri8R5WGVIyfpgY67iLQRXLazt8z2261Rfag8FW5y5adeTjTeXhLAYUayR3iSU9H SCWA== MIME-Version: 1.0 Received: by 10.180.86.132 with SMTP id p4mr9119342wiz.15.1335989049327; Wed, 02 May 2012 13:04:09 -0700 (PDT) Received: by 10.223.155.74 with HTTP; Wed, 2 May 2012 13:04:09 -0700 (PDT) In-Reply-To: References: <201205011615.q41GFZa1034278@svn.freebsd.org> Date: Wed, 2 May 2012 22:04:09 +0200 Message-ID: From: Monthadar Al Jaberi To: "Bjoern A. Zeeb" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Monthadar Al Jaberi , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234893 - head/sbin/ifconfig X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 20:04:11 -0000 On Tue, May 1, 2012 at 11:05 PM, Bjoern A. Zeeb wrote: > > On 1. May 2012, at 16:15 , Monthadar Al Jaberi wrote: > >> Author: monthadar >> Date: Tue May =A01 16:15:34 2012 >> New Revision: 234893 >> URL: http://svn.freebsd.org/changeset/base/234893 >> >> Log: >> =A0* Added new command to ifconfig to activate Mesh Gate Announcement ca= lled >> =A0meshgate with corresponding explanation; >> >> =A0Approved by: adrian >> >> Modified: >> =A0head/sbin/ifconfig/ifconfig.8 >> =A0head/sbin/ifconfig/ifieee80211.c >> >> Modified: head/sbin/ifconfig/ifconfig.8 >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/sbin/ifconfig/ifconfig.8 =A0 =A0 Tue May =A01 16:14:18 2012 =A0= =A0 =A0 =A0(r234892) >> +++ head/sbin/ifconfig/ifconfig.8 =A0 =A0 Tue May =A01 16:15:34 2012 =A0= =A0 =A0 =A0(r234893) > > > Please update .Dd as well. Done. Thank you. > >> @@ -1979,6 +1979,12 @@ Enable or disable forwarding packets by >> By default >> .Cm meshforward >> is enabled. >> +.It Cm meshgate >> +This attribute specifies whether or not the mesh STA activates mesh gat= e >> +announcements. >> +By default >> +.Cm meshgate >> +is disabled. >> .It Cm meshmetric Ar protocol >> Set the specified >> .Ar protocol > > -- > Bjoern A. Zeeb =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 You have to have visions! > =A0 It does not matter how good you are. It matters what good you do! > --=20 Monthadar Al Jaberi From owner-svn-src-head@FreeBSD.ORG Wed May 2 20:56:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E0181106566C; Wed, 2 May 2012 20:56:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id B4AE48FC15; Wed, 2 May 2012 20:56:07 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 24717B96D; Wed, 2 May 2012 16:56:07 -0400 (EDT) From: John Baldwin To: Doug Barton Date: Wed, 2 May 2012 16:34:21 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201205021425.q42EPdqw088857@svn.freebsd.org> <4FA18A1B.30203@FreeBSD.org> In-Reply-To: <4FA18A1B.30203@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201205021634.21898.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 02 May 2012 16:56:07 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234927 - in head: etc/rc.d sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 20:56:08 -0000 On Wednesday, May 02, 2012 3:25:15 pm Doug Barton wrote: > On 5/2/2012 7:25 AM, John Baldwin wrote: > > - Simplify accounting log rotation a bit. There is no need to re-run > > accton(8) after renaming the new log file to it's real name. > > Have you thoroughly tested this change? I remember adding that on > purpose, but I couldn't tell you for sure at this point exactly why. The reporter tested it. However, the kernel has no notion of the pathname once it has opened the file. It just holds a reference to the vnode directly, and the rename of the file will not invalidate that reference. -- John Baldwin From owner-svn-src-head@FreeBSD.ORG Wed May 2 21:24:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E2B76106566C; Wed, 2 May 2012 21:24:08 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B45F08FC12; Wed, 2 May 2012 21:24:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42LO8iE003890; Wed, 2 May 2012 21:24:08 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42LO82Q003888; Wed, 2 May 2012 21:24:08 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201205022124.q42LO82Q003888@svn.freebsd.org> From: Jamie Gritton Date: Wed, 2 May 2012 21:24:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234934 - head/usr.sbin/jail X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 21:24:09 -0000 Author: jamie Date: Wed May 2 21:24:08 2012 New Revision: 234934 URL: http://svn.freebsd.org/changeset/base/234934 Log: Add YY_NO_INPUT so clang doesn't complain about "input" not being used. Modified: head/usr.sbin/jail/jaillex.l Modified: head/usr.sbin/jail/jaillex.l ============================================================================== --- head/usr.sbin/jail/jaillex.l Wed May 2 20:01:28 2012 (r234933) +++ head/usr.sbin/jail/jaillex.l Wed May 2 21:24:08 2012 (r234934) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include "jailp.h" #include "y.tab.h" +#define YY_NO_INPUT #define YY_NO_UNPUT extern int yynerrs; From owner-svn-src-head@FreeBSD.ORG Wed May 2 21:50:14 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 06C2A1065670; Wed, 2 May 2012 21:50:14 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E592A8FC14; Wed, 2 May 2012 21:50:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q42LoDZY004814; Wed, 2 May 2012 21:50:13 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q42LoDh9004811; Wed, 2 May 2012 21:50:13 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201205022150.q42LoDh9004811@svn.freebsd.org> From: Eitan Adler Date: Wed, 2 May 2012 21:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234935 - in head/share/man: man5 man7 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 May 2012 21:50:14 -0000 Author: eadler Date: Wed May 2 21:50:13 2012 New Revision: 234935 URL: http://svn.freebsd.org/changeset/base/234935 Log: Prefer the use of csup to cvsup when talking about the binary. PR: docs/167459 Submitted by: "Bryan Drewery" Approved by: bcr MFC after: 1 week Modified: head/share/man/man5/make.conf.5 head/share/man/man7/development.7 Modified: head/share/man/man5/make.conf.5 ============================================================================== --- head/share/man/man5/make.conf.5 Wed May 2 21:24:08 2012 (r234934) +++ head/share/man/man5/make.conf.5 Wed May 2 21:50:13 2012 (r234935) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 11, 2011 +.Dd May 02, 2012 .Dt MAKE.CONF 5 .Os .Sh NAME @@ -318,7 +318,7 @@ The hostname of the sup server to use wh .It Va SUP_UPDATE .Pq Vt bool Set this to use -.Xr cvsup 1 +.Xr csup 1 to update your .Pa src , ports , doc and Modified: head/share/man/man7/development.7 ============================================================================== --- head/share/man/man7/development.7 Wed May 2 21:24:08 2012 (r234934) +++ head/share/man/man7/development.7 Wed May 2 21:50:13 2012 (r234935) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2002 +.Dd May 02, 2012 .Dt DEVELOPMENT 7 .Os .Sh NAME @@ -89,7 +89,7 @@ I recommend a partition of at least 5GB. .Pp On the master server, use -.Xr cvsup 1 Pq Pa ports/net/cvsup +.Xr csup 1 to automatically pull down and maintain the .Fx @@ -108,23 +108,23 @@ The job should look something like this (please randomize the time of day!). Note that you can use the -.Xr cvsup 1 +.Xr csup 1 configuration file example directly from .Pa /usr/share/examples without modification by supplying appropriate arguments to -.Xr cvsup 1 . +.Xr csup 1 . .Bd -literal -offset 4n -33 6 * * * /usr/local/bin/cvsup -g -r 20 -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/cvs-supfile +33 6 * * * /usr/bin/csup -r 20 -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/cvs-supfile .Ed .Pp Run the -.Xr cvsup 1 +.Xr csup 1 manually the first time to pull down the archive. It could take all day depending on how fast your connection is! You will run all -.Xr cvsup 1 +.Xr csup 1 and .Xr cvs 1 operations as @@ -555,7 +555,7 @@ Since the main tree is based on CVS, the former is convenient. .Pp First, you need to modify your -.Xr cvsup 1 +.Xr csup 1 environment to avoid it modifying the local changes you have committed to the repository. It is important to remove the @@ -568,7 +568,7 @@ subdirectory to your .Pa refuse file. For more information, see -.Xr cvsup 1 . +.Xr csup 1 . .Pp The .Fx @@ -598,13 +598,13 @@ For more information on using CVS, see .Pp .Sy WARNING! The -.Xr cvsup 1 +.Xr csup 1 utility may blow away changes made on a local branch in some situations. This has been reported to occur when the master CVS repository is directly manipulated or an RCS file is changed. At this point, -.Xr cvsup 1 +.Xr csup 1 notices that the client and server have entirely different RCS files, so it does a full replace instead of trying to send just deltas. @@ -619,7 +619,7 @@ Bottom line is, if you value your local should back it up before every update. .Sh UPDATING VIA CVS The advantage of using -.Xr cvsup 1 +.Xr csup 1 to maintain an updated copy of the CVS repository instead of using it to maintain source trees directly is that you can then pick and choose when you bring your source tree (or pieces of your From owner-svn-src-head@FreeBSD.ORG Thu May 3 01:41:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 910941065670; Thu, 3 May 2012 01:41:13 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CDCD8FC15; Thu, 3 May 2012 01:41:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q431fD92012832; Thu, 3 May 2012 01:41:13 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q431fDO1012830; Thu, 3 May 2012 01:41:13 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201205030141.q431fDO1012830@svn.freebsd.org> From: Ed Maste Date: Thu, 3 May 2012 01:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234936 - head/sys/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 01:41:13 -0000 Author: emaste Date: Thu May 3 01:41:12 2012 New Revision: 234936 URL: http://svn.freebsd.org/changeset/base/234936 Log: Relax restriction on direct tx to child ports Lagg(4) restricts the type of packet that may be sent directly to a child port, to avoid undesired output from accidental misconfiguration. Previously only ETHERTYPE_PAE was permitted. BPF writes to a lagg(4) child port are presumably intentional, so just allow them, while still blocking other packets that should take the aggregation path. PR: kern/138620 Approved by: thompsa@ Modified: head/sys/net/if_lagg.c Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Wed May 2 21:50:13 2012 (r234935) +++ head/sys/net/if_lagg.c Thu May 3 01:41:12 2012 (r234936) @@ -764,28 +764,18 @@ fallback: return (EINVAL); } +/* + * For direct output to child ports. + */ static int lagg_port_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct route *ro) { struct lagg_port *lp = ifp->if_lagg; - struct ether_header *eh; - short type = 0; switch (dst->sa_family) { case pseudo_AF_HDRCMPLT: case AF_UNSPEC: - eh = (struct ether_header *)dst->sa_data; - type = eh->ether_type; - break; - } - - /* - * Only allow ethernet types required to initiate or maintain the link, - * aggregated frames take a different path. - */ - switch (ntohs(type)) { - case ETHERTYPE_PAE: /* EAPOL PAE/802.1x */ return ((*lp->lp_output)(ifp, m, dst, ro)); } From owner-svn-src-head@FreeBSD.ORG Thu May 3 05:32:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 34B82106564A; Thu, 3 May 2012 05:32:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E6EB8FC0A; Thu, 3 May 2012 05:32:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q435WuTN021395; Thu, 3 May 2012 05:32:56 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q435Wule021387; Thu, 3 May 2012 05:32:56 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205030532.q435Wule021387@svn.freebsd.org> From: Alexander Motin Date: Thu, 3 May 2012 05:32:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234940 - in head: sbin/geom/class/raid sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 05:32:57 -0000 Author: mav Date: Thu May 3 05:32:56 2012 New Revision: 234940 URL: http://svn.freebsd.org/changeset/base/234940 Log: Add optional -o argument to the `graid label ` to specify some metadata format options. Use it for specifying byte order for the DDF metadata: big-endian defined by specification and little-endian used by Adaptec. Modified: head/sbin/geom/class/raid/geom_raid.c head/sbin/geom/class/raid/graid.8 head/sys/geom/raid/g_raid.c head/sys/geom/raid/g_raid.h head/sys/geom/raid/g_raid_ctl.c head/sys/geom/raid/g_raid_md_if.m head/sys/geom/raid/md_ddf.c Modified: head/sbin/geom/class/raid/geom_raid.c ============================================================================== --- head/sbin/geom/class/raid/geom_raid.c Thu May 3 05:04:37 2012 (r234939) +++ head/sbin/geom/class/raid/geom_raid.c Thu May 3 05:32:56 2012 (r234940) @@ -48,11 +48,12 @@ struct g_command class_commands[] = { { "label", G_FLAG_VERBOSE, NULL, { { 'f', "force", NULL, G_TYPE_BOOL }, + { 'o', "fmtopt", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'S', "size", G_VAL_OPTIONAL, G_TYPE_NUMBER }, { 's', "strip", G_VAL_OPTIONAL, G_TYPE_NUMBER }, G_OPT_SENTINEL }, - "[-fv] [-S size] [-s stripsize] format label level prov ..." + "[-fv] [-o fmtopt] [-S size] [-s stripsize] format label level prov ..." }, { "add", G_FLAG_VERBOSE, NULL, { Modified: head/sbin/geom/class/raid/graid.8 ============================================================================== --- head/sbin/geom/class/raid/graid.8 Thu May 3 05:04:37 2012 (r234939) +++ head/sbin/geom/class/raid/graid.8 Thu May 3 05:32:56 2012 (r234940) @@ -34,6 +34,7 @@ .Nm .Cm label .Op Fl f +.Op Fl o Ar fmtopt .Op Fl S Ar size .Op Fl s Ar strip .Ar format @@ -119,6 +120,8 @@ Additional options include: .It Fl f Enforce specified configuration creation if it is officially unsupported, but technically can be created. +.It Fl o Ar fmtopt +Specifies metadata format options. .It Fl S Ar size Use .Ar size @@ -205,14 +208,18 @@ The format defined by the SNIA Common RA Used by some Adaptec RAID BIOSes and some hardware RAID controllers. Because of high format flexibility different implementations support different set of features and have different on-disk metadata layouts. -To provide compatibility, the GEOM RAID class mimics capabilities and -metadata layout of the first detected DDF array. +To provide compatibility, the GEOM RAID class mimics capabilities +of the first detected DDF array. Respecting that, it may support different number of disks per volume, volumes per array, partitions per disk, etc. The following configurations are supported: RAID0 (2+ disks), RAID1 (2+ disks), RAID1E (3+ disks), RAID3 (3+ disks), RAID4 (3+ disks), RAID5 (3+ disks), RAID5E (4+ disks), RAID5EE (4+ disks), RAID5R (3+ disks), RAID6 (4+ disks), RAIDMDF (5+ disks), RAID10 (4+ disks), SINGLE (1 disk), CONCAT (2+ disks). +.Pp +Format supports two options "BE" and "LE", that mean big-endian byte order +defined by specification (default) and little-endian used by some Adaptec +controllers. .It Intel The format used by Intel RAID BIOS. Supports up to two volumes per array. Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid.c Thu May 3 05:32:56 2012 (r234940) @@ -2143,7 +2143,7 @@ g_raid_taste(struct g_class *mp, struct g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name); G_RAID_DEBUG(2, "Tasting provider %s.", pp->name); - gp = g_new_geomf(mp, "mirror:taste"); + gp = g_new_geomf(mp, "raid:taste"); /* * This orphan function should be never called. */ @@ -2173,7 +2173,8 @@ g_raid_taste(struct g_class *mp, struct } int -g_raid_create_node_format(const char *format, struct g_geom **gp) +g_raid_create_node_format(const char *format, struct gctl_req *req, + struct g_geom **gp) { struct g_raid_md_class *class; struct g_raid_md_object *obj; @@ -2191,7 +2192,7 @@ g_raid_create_node_format(const char *fo obj = (void *)kobj_create((kobj_class_t)class, M_RAID, M_WAITOK); obj->mdo_class = class; - status = G_RAID_MD_CREATE(obj, &g_raid_class, gp); + status = G_RAID_MD_CREATE_REQ(obj, &g_raid_class, req, gp); if (status != G_RAID_MD_TASTE_NEW) kobj_delete((kobj_t)obj, M_RAID); return (status); Modified: head/sys/geom/raid/g_raid.h ============================================================================== --- head/sys/geom/raid/g_raid.h Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid.h Thu May 3 05:32:56 2012 (r234940) @@ -382,7 +382,8 @@ const char * g_raid_disk_state2str(int s struct g_raid_softc * g_raid_create_node(struct g_class *mp, const char *name, struct g_raid_md_object *md); -int g_raid_create_node_format(const char *format, struct g_geom **gp); +int g_raid_create_node_format(const char *format, struct gctl_req *req, + struct g_geom **gp); struct g_raid_volume * g_raid_create_volume(struct g_raid_softc *sc, const char *name, int id); struct g_raid_disk * g_raid_create_disk(struct g_raid_softc *sc); Modified: head/sys/geom/raid/g_raid_ctl.c ============================================================================== --- head/sys/geom/raid/g_raid_ctl.c Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid_ctl.c Thu May 3 05:32:56 2012 (r234940) @@ -88,7 +88,7 @@ g_raid_ctl_label(struct gctl_req *req, s gctl_error(req, "No format recieved."); return; } - crstatus = g_raid_create_node_format(format, &geom); + crstatus = g_raid_create_node_format(format, req, &geom); if (crstatus == G_RAID_MD_TASTE_FAIL) { gctl_error(req, "Failed to create array with format '%s'.", format); Modified: head/sys/geom/raid/g_raid_md_if.m ============================================================================== --- head/sys/geom/raid/g_raid_md_if.m Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/g_raid_md_if.m Thu May 3 05:32:56 2012 (r234940) @@ -49,13 +49,22 @@ HEADER { # Default implementations of methods. CODE { static int - g_raid_md_create_default(struct g_raid_md_object *md) + g_raid_md_create_default(struct g_raid_md_object *md, + struct g_class *mp, struct g_geom **gp) { return (G_RAID_MD_TASTE_FAIL); } static int + g_raid_md_create_req_default(struct g_raid_md_object *md, + struct g_class *mp, struct gctl_req *req, struct g_geom **gp) + { + + return (G_RAID_MD_CREATE(md, mp, gp)); + } + + static int g_raid_md_ctl_default(struct g_raid_md_object *md, struct gctl_req *req) { @@ -95,6 +104,14 @@ METHOD int create { struct g_geom **gp; } DEFAULT g_raid_md_create_default; +# create_req() - create new node from scratch, with request argument. +METHOD int create_req { + struct g_raid_md_object *md; + struct g_class *mp; + struct gctl_req *req; + struct g_geom **gp; +} DEFAULT g_raid_md_create_req_default; + # taste() - taste disk and, if needed, create new node. METHOD int taste { struct g_raid_md_object *md; Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Thu May 3 05:04:37 2012 (r234939) +++ head/sys/geom/raid/md_ddf.c Thu May 3 05:32:56 2012 (r234940) @@ -88,6 +88,7 @@ struct g_raid_md_ddf_pervolume { struct g_raid_md_ddf_object { struct g_raid_md_object mdio_base; + u_int mdio_bigendian; struct ddf_meta mdio_meta; int mdio_starting; struct callout mdio_start_co; /* STARTING state timer. */ @@ -95,7 +96,7 @@ struct g_raid_md_ddf_object { struct root_hold_token *mdio_rootmount; /* Root mount delay token. */ }; -static g_raid_md_create_t g_raid_md_create_ddf; +static g_raid_md_create_req_t g_raid_md_create_req_ddf; static g_raid_md_taste_t g_raid_md_taste_ddf; static g_raid_md_event_t g_raid_md_event_ddf; static g_raid_md_volume_event_t g_raid_md_volume_event_ddf; @@ -107,7 +108,7 @@ static g_raid_md_free_volume_t g_raid_md static g_raid_md_free_t g_raid_md_free_ddf; static kobj_method_t g_raid_md_ddf_methods[] = { - KOBJMETHOD(g_raid_md_create, g_raid_md_create_ddf), + KOBJMETHOD(g_raid_md_create_req, g_raid_md_create_req_ddf), KOBJMETHOD(g_raid_md_taste, g_raid_md_taste_ddf), KOBJMETHOD(g_raid_md_event, g_raid_md_event_ddf), KOBJMETHOD(g_raid_md_volume_event, g_raid_md_volume_event_ddf), @@ -562,6 +563,7 @@ ddf_meta_create(struct g_raid_disk *disk struct timespec ts; struct clocktime ct; struct g_raid_md_ddf_perdisk *pd; + struct g_raid_md_ddf_object *mdi; struct ddf_meta *meta; struct ddf_pd_entry *pde; off_t anchorlba; @@ -572,13 +574,14 @@ ddf_meta_create(struct g_raid_disk *disk if (sample->hdr == NULL) sample = NULL; + mdi = (struct g_raid_md_ddf_object *)disk->d_softc->sc_md; pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; meta = &pd->pd_meta; ss = disk->d_consumer->provider->sectorsize; anchorlba = disk->d_consumer->provider->mediasize / ss - 1; meta->sectorsize = ss; - meta->bigendian = sample ? sample->bigendian : 0; + meta->bigendian = sample ? sample->bigendian : mdi->mdio_bigendian; getnanotime(&ts); clock_ts_to_ct(&ts, &ct); @@ -2012,11 +2015,26 @@ g_raid_md_ddf_new_disk(struct g_raid_dis } static int -g_raid_md_create_ddf(struct g_raid_md_object *md, struct g_class *mp, - struct g_geom **gp) +g_raid_md_create_req_ddf(struct g_raid_md_object *md, struct g_class *mp, + struct gctl_req *req, struct g_geom **gp) { struct g_geom *geom; struct g_raid_softc *sc; + struct g_raid_md_ddf_object *mdi, *mdi1; + char name[16]; + const char *fmtopt; + int be = 1; + + mdi = (struct g_raid_md_ddf_object *)md; + fmtopt = gctl_get_asciiparam(req, "fmtopt"); + if (fmtopt == NULL || strcasecmp(fmtopt, "BE") == 0) + be = 1; + else if (strcasecmp(fmtopt, "LE") == 0) + be = 0; + else { + gctl_error(req, "Incorrect fmtopt argument."); + return (G_RAID_MD_TASTE_FAIL); + } /* Search for existing node. */ LIST_FOREACH(geom, &mp->geom, geom) { @@ -2027,6 +2045,9 @@ g_raid_md_create_ddf(struct g_raid_md_ob continue; if (sc->sc_md->mdo_class != md->mdo_class) continue; + mdi1 = (struct g_raid_md_ddf_object *)sc->sc_md; + if (mdi1->mdio_bigendian != be) + continue; break; } if (geom != NULL) { @@ -2035,7 +2056,9 @@ g_raid_md_create_ddf(struct g_raid_md_ob } /* Create new one if not found. */ - sc = g_raid_create_node(mp, "DDF", md); + mdi->mdio_bigendian = be; + snprintf(name, sizeof(name), "DDF%s", be ? "" : "-LE"); + sc = g_raid_create_node(mp, name, md); if (sc == NULL) return (G_RAID_MD_TASTE_FAIL); md->mdo_softc = sc; @@ -2053,11 +2076,13 @@ g_raid_md_taste_ddf(struct g_raid_md_obj struct g_raid_disk *disk; struct ddf_meta meta; struct g_raid_md_ddf_perdisk *pd; + struct g_raid_md_ddf_object *mdi; struct g_geom *geom; - int error, result, len; + int error, result, len, be; char name[16]; G_RAID_DEBUG(1, "Tasting DDF on %s", cp->provider->name); + mdi = (struct g_raid_md_ddf_object *)md; pp = cp->provider; /* Read metadata from device. */ @@ -2070,6 +2095,7 @@ g_raid_md_taste_ddf(struct g_raid_md_obj g_access(cp, -1, 0, 0); if (error != 0) return (G_RAID_MD_TASTE_FAIL); + be = meta.bigendian; /* Metadata valid. Print it. */ g_raid_md_ddf_print(&meta); @@ -2084,6 +2110,9 @@ g_raid_md_taste_ddf(struct g_raid_md_obj continue; if (sc->sc_md->mdo_class != md->mdo_class) continue; + mdi = (struct g_raid_md_ddf_object *)sc->sc_md; + if (mdi->mdio_bigendian != be) + continue; break; } @@ -2094,7 +2123,8 @@ g_raid_md_taste_ddf(struct g_raid_md_obj } else { /* Not found matching node -- create one. */ result = G_RAID_MD_TASTE_NEW; - snprintf(name, sizeof(name), "DDF"); + mdi->mdio_bigendian = be; + snprintf(name, sizeof(name), "DDF%s", be ? "" : "-LE"); sc = g_raid_create_node(mp, name, md); md->mdo_softc = sc; geom = sc->sc_geom; From owner-svn-src-head@FreeBSD.ORG Thu May 3 05:52:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 63655106568E; Thu, 3 May 2012 05:52:40 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4E6DA8FC0C; Thu, 3 May 2012 05:52:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q435qebH022094; Thu, 3 May 2012 05:52:40 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q435qemq022092; Thu, 3 May 2012 05:52:40 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205030552.q435qemq022092@svn.freebsd.org> From: Adrian Chadd Date: Thu, 3 May 2012 05:52:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234941 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 05:52:40 -0000 Author: adrian Date: Thu May 3 05:52:39 2012 New Revision: 234941 URL: http://svn.freebsd.org/changeset/base/234941 Log: Fix a totally bone-headed, last minute bounds check snafu that somehow I must've missed when booting a test kernel. This has been validated on the AR7161. Modified: head/sys/mips/atheros/ar71xx_chip.c Modified: head/sys/mips/atheros/ar71xx_chip.c ============================================================================== --- head/sys/mips/atheros/ar71xx_chip.c Thu May 3 05:32:56 2012 (r234940) +++ head/sys/mips/atheros/ar71xx_chip.c Thu May 3 05:52:39 2012 (r234941) @@ -192,21 +192,23 @@ ar71xx_chip_set_mii_if(uint32_t unit, ui mii_if = MII0_CTRL_IF_RGMII; else if (mii_mode == AR71XX_MII_MODE_RMII) mii_if = MII0_CTRL_IF_RMII; - else + else { printf("%s: invalid MII mode (%d) for unit %d\n", __func__, mii_mode, unit); return; + } break; case 1: reg = AR71XX_MII1_CTRL; if (mii_mode == AR71XX_MII_MODE_RGMII) mii_if = MII1_CTRL_IF_RGMII; - if (mii_mode == AR71XX_MII_MODE_RMII) + else if (mii_mode == AR71XX_MII_MODE_RMII) mii_if = MII1_CTRL_IF_RMII; - else + else { printf("%s: invalid MII mode (%d) for unit %d\n", __func__, mii_mode, unit); return; + } break; default: printf("%s: invalid MII unit set for arge unit: %d\n", From owner-svn-src-head@FreeBSD.ORG Thu May 3 07:22:30 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1EA901065673; Thu, 3 May 2012 07:22:30 +0000 (UTC) (envelope-from daichi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 08D9C8FC12; Thu, 3 May 2012 07:22:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q437MTSe025468; Thu, 3 May 2012 07:22:29 GMT (envelope-from daichi@svn.freebsd.org) Received: (from daichi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q437MTrh025466; Thu, 3 May 2012 07:22:29 GMT (envelope-from daichi@svn.freebsd.org) Message-Id: <201205030722.q437MTrh025466@svn.freebsd.org> From: Daichi GOTO Date: Thu, 3 May 2012 07:22:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234944 - head/sys/fs/unionfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 07:22:30 -0000 Author: daichi Date: Thu May 3 07:22:29 2012 New Revision: 234944 URL: http://svn.freebsd.org/changeset/base/234944 Log: fixed a unionfs_readdir math issue PR: 132987 Submitted by: Matthew Fleming Modified: head/sys/fs/unionfs/union_vnops.c Modified: head/sys/fs/unionfs/union_vnops.c ============================================================================== --- head/sys/fs/unionfs/union_vnops.c Thu May 3 07:17:25 2012 (r234943) +++ head/sys/fs/unionfs/union_vnops.c Thu May 3 07:22:29 2012 (r234944) @@ -1642,7 +1642,7 @@ unionfs_readdir(struct vop_readdir_args pos = newcookies; memcpy(pos, cookies_bk, ncookies_bk * sizeof(u_long)); - pos += ncookies_bk * sizeof(u_long); + pos += ncookies_bk; memcpy(pos, *(ap->a_cookies), *(ap->a_ncookies) * sizeof(u_long)); free(cookies_bk, M_TEMP); free(*(ap->a_cookies), M_TEMP); From owner-svn-src-head@FreeBSD.ORG Thu May 3 07:48:20 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6C760106566B; Thu, 3 May 2012 07:48:20 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 573D38FC19; Thu, 3 May 2012 07:48:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q437mK08026460; Thu, 3 May 2012 07:48:20 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q437mKH9026458; Thu, 3 May 2012 07:48:20 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205030748.q437mKH9026458@svn.freebsd.org> From: Adrian Chadd Date: Thu, 3 May 2012 07:48:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234945 - head/sys/mips/conf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 07:48:20 -0000 Author: adrian Date: Thu May 3 07:48:19 2012 New Revision: 234945 URL: http://svn.freebsd.org/changeset/base/234945 Log: In the new world order, multiphy is now when the phymask is 0x0. This makes the TP-WN1043ND (ar913x based) work again. Modified: head/sys/mips/conf/TP-WN1043ND.hints Modified: head/sys/mips/conf/TP-WN1043ND.hints ============================================================================== --- head/sys/mips/conf/TP-WN1043ND.hints Thu May 3 07:22:29 2012 (r234944) +++ head/sys/mips/conf/TP-WN1043ND.hints Thu May 3 07:48:19 2012 (r234945) @@ -4,7 +4,8 @@ # $FreeBSD$ # Hard-code the PHY for now, until there's switch phy support. -hint.arge.0.phymask=0x000c +# hint.arge.0.phymask=0x000c +hint.arge.0.phymask=0x0000 hint.arge.0.media=1000 hint.arge.0.fduplex=1 # Where is the MAC address stored in flash for this particular unit. From owner-svn-src-head@FreeBSD.ORG Thu May 3 08:56:44 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A59991065673; Thu, 3 May 2012 08:56:44 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DE618FC17; Thu, 3 May 2012 08:56:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q438ui8L028957; Thu, 3 May 2012 08:56:44 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q438ui7R028950; Thu, 3 May 2012 08:56:44 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201205030856.q438ui7R028950@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Thu, 3 May 2012 08:56:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234946 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 08:56:44 -0000 Author: melifaro Date: Thu May 3 08:56:43 2012 New Revision: 234946 URL: http://svn.freebsd.org/changeset/base/234946 Log: Revert r234834 per luigi@ request. Cleaner solution (e.g. adding another header) should be done here. Original log: Move several enums and structures required for L2 filtering from ip_fw_private.h to ip_fw.h. Remove ipfw/ip_fw_private.h header from non-ipfw code. Requested by: luigi Approved by: kib(mentor) Modified: head/sys/contrib/pf/net/pf.c head/sys/net/if_bridge.c head/sys/net/if_ethersubr.c head/sys/netinet/ip_fw.h head/sys/netinet/ipfw/ip_fw_private.h head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Modified: head/sys/contrib/pf/net/pf.c ============================================================================== --- head/sys/contrib/pf/net/pf.c Thu May 3 07:48:19 2012 (r234945) +++ head/sys/contrib/pf/net/pf.c Thu May 3 08:56:43 2012 (r234946) @@ -122,6 +122,7 @@ __FBSDID("$FreeBSD$"); #include #ifdef __FreeBSD__ #include +#include /* XXX: only for DIR_IN/DIR_OUT */ #endif #ifndef __FreeBSD__ Modified: head/sys/net/if_bridge.c ============================================================================== --- head/sys/net/if_bridge.c Thu May 3 07:48:19 2012 (r234945) +++ head/sys/net/if_bridge.c Thu May 3 08:56:43 2012 (r234946) @@ -132,6 +132,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include /* * Size of the route hash table. Must be a power of two. Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Thu May 3 07:48:19 2012 (r234945) +++ head/sys/net/if_ethersubr.c Thu May 3 08:56:43 2012 (r234946) @@ -72,6 +72,7 @@ #include #include #include +#include #endif #ifdef INET6 #include Modified: head/sys/netinet/ip_fw.h ============================================================================== --- head/sys/netinet/ip_fw.h Thu May 3 07:48:19 2012 (r234945) +++ head/sys/netinet/ip_fw.h Thu May 3 08:56:43 2012 (r234946) @@ -545,88 +545,6 @@ struct ipfw_flow_id { #define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) -#ifdef _KERNEL -/* Return values from ipfw_[ether_]chk() */ -enum { - IP_FW_PASS = 0, - IP_FW_DENY, - IP_FW_DIVERT, - IP_FW_TEE, - IP_FW_DUMMYNET, - IP_FW_NETGRAPH, - IP_FW_NGTEE, - IP_FW_NAT, - IP_FW_REASS, -}; - -/* - * Hooks sometime need to know the direction of the packet - * (divert, dummynet, netgraph, ...) - * We use a generic definition here, with bit0-1 indicating the - * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the - * specific protocol (if necessary) - */ -enum { - DIR_MASK = 0x3, - DIR_OUT = 0, - DIR_IN = 1, - DIR_FWD = 2, - DIR_DROP = 3, - PROTO_LAYER2 = 0x4, /* set for layer 2 */ - /* PROTO_DEFAULT = 0, */ - PROTO_IPV4 = 0x08, - PROTO_IPV6 = 0x10, - PROTO_IFB = 0x0c, /* layer2 + ifbridge */ - /* PROTO_OLDBDG = 0x14, unused, old bridge */ -}; - -/* - * Structure for collecting parameters to dummynet for ip6_output forwarding - */ -struct _ip6dn_args { - struct ip6_pktopts *opt_or; - struct route_in6 ro_or; - int flags_or; - struct ip6_moptions *im6o_or; - struct ifnet *origifp_or; - struct ifnet *ifp_or; - struct sockaddr_in6 dst_or; - u_long mtu_or; - struct route_in6 ro_pmtu_or; -}; - -/* - * Arguments for calling ipfw_chk() and dummynet_io(). We put them - * all into a structure because this way it is easier and more - * efficient to pass variables around and extend the interface. - */ -struct ip_fw_args { - struct mbuf *m; /* the mbuf chain */ - struct ifnet *oif; /* output interface */ - struct sockaddr_in *next_hop; /* forward address */ - struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ - - /* - * On return, it points to the matching rule. - * On entry, rule.slot > 0 means the info is valid and - * contains the starting rule for an ipfw search. - * If chain_id == chain->id && slot >0 then jump to that slot. - * Otherwise, we locate the first rule >= rulenum:rule_id - */ - struct ipfw_rule_ref rule; /* match/restart info */ - - struct ether_header *eh; /* for bridged packets */ - - struct ipfw_flow_id f_id; /* grabbed from IP header */ - //uint32_t cookie; /* a cookie depending on rule action */ - struct inpcb *inp; - - struct _ip6dn_args dummypar; /* dummynet->ip6_output */ - struct sockaddr_in hopstore; /* store here if cannot use a pointer */ -}; - -#endif /* _KERNEL */ - /* * Dynamic ipfw rule. */ Modified: head/sys/netinet/ipfw/ip_fw_private.h ============================================================================== --- head/sys/netinet/ipfw/ip_fw_private.h Thu May 3 07:48:19 2012 (r234945) +++ head/sys/netinet/ipfw/ip_fw_private.h Thu May 3 08:56:43 2012 (r234946) @@ -48,8 +48,89 @@ #define SYSEND #endif +/* Return values from ipfw_chk() */ +enum { + IP_FW_PASS = 0, + IP_FW_DENY, + IP_FW_DIVERT, + IP_FW_TEE, + IP_FW_DUMMYNET, + IP_FW_NETGRAPH, + IP_FW_NGTEE, + IP_FW_NAT, + IP_FW_REASS, +}; + +/* + * Structure for collecting parameters to dummynet for ip6_output forwarding + */ +struct _ip6dn_args { + struct ip6_pktopts *opt_or; + struct route_in6 ro_or; + int flags_or; + struct ip6_moptions *im6o_or; + struct ifnet *origifp_or; + struct ifnet *ifp_or; + struct sockaddr_in6 dst_or; + u_long mtu_or; + struct route_in6 ro_pmtu_or; +}; + + +/* + * Arguments for calling ipfw_chk() and dummynet_io(). We put them + * all into a structure because this way it is easier and more + * efficient to pass variables around and extend the interface. + */ +struct ip_fw_args { + struct mbuf *m; /* the mbuf chain */ + struct ifnet *oif; /* output interface */ + struct sockaddr_in *next_hop; /* forward address */ + struct sockaddr_in6 *next_hop6; /* ipv6 forward address */ + + /* + * On return, it points to the matching rule. + * On entry, rule.slot > 0 means the info is valid and + * contains the starting rule for an ipfw search. + * If chain_id == chain->id && slot >0 then jump to that slot. + * Otherwise, we locate the first rule >= rulenum:rule_id + */ + struct ipfw_rule_ref rule; /* match/restart info */ + + struct ether_header *eh; /* for bridged packets */ + + struct ipfw_flow_id f_id; /* grabbed from IP header */ + //uint32_t cookie; /* a cookie depending on rule action */ + struct inpcb *inp; + + struct _ip6dn_args dummypar; /* dummynet->ip6_output */ + struct sockaddr_in hopstore; /* store here if cannot use a pointer */ +}; + MALLOC_DECLARE(M_IPFW); +/* + * Hooks sometime need to know the direction of the packet + * (divert, dummynet, netgraph, ...) + * We use a generic definition here, with bit0-1 indicating the + * direction, bit 2 indicating layer2 or 3, bit 3-4 indicating the + * specific protocol + * indicating the protocol (if necessary) + */ +enum { + DIR_MASK = 0x3, + DIR_OUT = 0, + DIR_IN = 1, + DIR_FWD = 2, + DIR_DROP = 3, + PROTO_LAYER2 = 0x4, /* set for layer 2 */ + /* PROTO_DEFAULT = 0, */ + PROTO_IPV4 = 0x08, + PROTO_IPV6 = 0x10, + PROTO_IFB = 0x0c, /* layer2 + ifbridge */ + /* PROTO_OLDBDG = 0x14, unused, old bridge */ +}; + /* wrapper for freeing a packet, in case we need to do more work */ #ifndef FREE_PKT #if defined(__linux__) || defined(_WIN32) Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h ============================================================================== --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Thu May 3 07:48:19 2012 (r234945) +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h Thu May 3 08:56:43 2012 (r234946) @@ -68,6 +68,7 @@ #include #include #include +#include #endif #ifdef INET6 #include From owner-svn-src-head@FreeBSD.ORG Thu May 3 09:04:55 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by hub.freebsd.org (Postfix) with ESMTP id 9CB30106566C; Thu, 3 May 2012 09:04:55 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from dhcp170-36-red.yandex.net (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx2.freebsd.org (Postfix) with ESMTP id D20951508CC; Thu, 3 May 2012 09:04:53 +0000 (UTC) Message-ID: <4FA24920.4080809@FreeBSD.org> Date: Thu, 03 May 2012 13:00:16 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111117 Thunderbird/8.0 MIME-Version: 1.0 To: Luigi Rizzo References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> <4F9E82DA.4030406@FreeBSD.org> <20120430133904.GA65792@onelab2.iet.unipi.it> In-Reply-To: <20120430133904.GA65792@onelab2.iet.unipi.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, Gleb Smirnoff , src-committers@FreeBSD.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:04:55 -0000 On 30.04.2012 17:39, Luigi Rizzo wrote: > On Mon, Apr 30, 2012 at 04:17:30PM +0400, Alexander V. Chernikov wrote: >> On 30.04.2012 15:36, Gleb Smirnoff wrote: >>> On Mon, Apr 30, 2012 at 01:48:36PM +0200, Luigi Rizzo wrote: >>> L> On Mon, Apr 30, 2012 at 10:22:23AM +0000, Alexander V. Chernikov wrote: >>> L> > Author: melifaro >>> L> > Date: Mon Apr 30 10:22:23 2012 >>> L> > New Revision: 234834 >>> L> > URL: http://svn.freebsd.org/changeset/base/234834 >>> L> > >>> L> > Log: >>> L> > Move several enums and structures required for L2 filtering from >>> ip_fw_private.h to ip_fw.h. >>> L> >>> L> I would be really grateful if you could revert this back and discuss >>> L> what you wanted to achieve with this change other than saving one >>> L> entry in the list of includes. >> Changing something inside ip_fw_private.h (for example, locking change) >> requires changes in several totally unrelated subsystems, which is >> clearly bad. > > There are certainly good reasons to split things even further > (as Gleb suggested) so if you want to follow that route > and have patches for review i will be glad to discuss that. Yup. I'll make another patch > > I am the first one to say that the name ip_fw_private.h is confusing, > but at the time i did not feel brave enough to move from a single > header (ip_fw.h) to the four (ip_fw.h, ip_fw_user.h, ip_fw_kernel.h, > ip_fw_kernel_private.h) that would be needed for proper confinement > of information. > > This said, the change you have made introduce a worse form of header > pollution and this is why i am requesting a backout. Reverted in r234946 > >>> L> >>> L> As clearly mentioned in the commit logs >>> L> >>> L> http://svnweb.freebsd.org/base?view=revision&revision=200580 >> Maybe there are some other possibilities documenting preferred layout >> other than commit log? Searching 2+yrs commit history is not the best >> way of finding information. > > sure, you could have asked people involved with ipfw development > to review this change. > > Also don't expect a single policy in style(9) to hold for all > possible situations: the kernel is huge, it has parts that come > from multiple origins in time and space, and sometimes is shared > with other OSs as well. Refactoring (such as your changes) should > keep that in mind. > > Let's not make a big deal of this thing: we all make mistakes or > have different opinions on how things should be done, and the only > way to avoid them is to discuss thing in advance, or be open to > resolve things when problems arise. No hard feelings. Ok :) > > cheers > luigi > -- WBR, Alexander From owner-svn-src-head@FreeBSD.ORG Thu May 3 09:17:32 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0B05D106566B; Thu, 3 May 2012 09:17:32 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D066D8FC0C; Thu, 3 May 2012 09:17:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q439HVYA029732; Thu, 3 May 2012 09:17:31 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q439HVln029728; Thu, 3 May 2012 09:17:31 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201205030917.q439HVln029728@svn.freebsd.org> From: David Xu Date: Thu, 3 May 2012 09:17:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234947 - head/lib/libthr/thread X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 09:17:32 -0000 Author: davidxu Date: Thu May 3 09:17:31 2012 New Revision: 234947 URL: http://svn.freebsd.org/changeset/base/234947 Log: MFp4: Enqueue thread in LIFO, this can cause starvation, but it gives better performance. Use _thr_queuefifo to control the frequency of FIFO vs LIFO, you can use environment string LIBPTHREAD_QUEUE_FIFO to configure the variable. Modified: head/lib/libthr/thread/thr_init.c head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_sleepq.c Modified: head/lib/libthr/thread/thr_init.c ============================================================================== --- head/lib/libthr/thread/thr_init.c Thu May 3 08:56:43 2012 (r234946) +++ head/lib/libthr/thread/thr_init.c Thu May 3 09:17:31 2012 (r234947) @@ -112,6 +112,7 @@ size_t _thr_stack_initial = THR_STACK_I int _thr_page_size; int _thr_spinloops; int _thr_yieldloops; +int _thr_queuefifo = 4; int _gc_count; struct umutex _mutex_static_lock = DEFAULT_UMUTEX; struct umutex _cond_static_lock = DEFAULT_UMUTEX; @@ -470,6 +471,9 @@ init_private(void) env = getenv("LIBPTHREAD_YIELDLOOPS"); if (env) _thr_yieldloops = atoi(env); + env = getenv("LIBPTHREAD_QUEUE_FIFO"); + if (env) + _thr_queuefifo = atoi(env); TAILQ_INIT(&_thr_atfork_list); } init_once = 1; Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Thu May 3 08:56:43 2012 (r234946) +++ head/lib/libthr/thread/thr_private.h Thu May 3 09:17:31 2012 (r234947) @@ -710,6 +710,7 @@ extern size_t _thr_stack_initial __hidde extern int _thr_page_size __hidden; extern int _thr_spinloops __hidden; extern int _thr_yieldloops __hidden; +extern int _thr_queuefifo __hidden; /* Garbage thread count. */ extern int _gc_count __hidden; Modified: head/lib/libthr/thread/thr_sleepq.c ============================================================================== --- head/lib/libthr/thread/thr_sleepq.c Thu May 3 08:56:43 2012 (r234946) +++ head/lib/libthr/thread/thr_sleepq.c Thu May 3 09:17:31 2012 (r234947) @@ -39,6 +39,7 @@ struct sleepqueue_chain { struct umutex sc_lock; + int sc_enqcnt; LIST_HEAD(, sleepqueue) sc_queues; int sc_type; }; @@ -124,7 +125,10 @@ _sleepq_add(void *wchan, struct pthread } td->sleepqueue = NULL; td->wchan = wchan; - TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle); + if (((++sc->sc_enqcnt << _thr_queuefifo) & 0xff) != 0) + TAILQ_INSERT_HEAD(&sq->sq_blocked, td, wle); + else + TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle); } int From owner-svn-src-head@FreeBSD.ORG Thu May 3 10:26:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7524E106564A; Thu, 3 May 2012 10:26:34 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 608078FC14; Thu, 3 May 2012 10:26:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43AQYiT032366; Thu, 3 May 2012 10:26:34 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43AQYFi032363; Thu, 3 May 2012 10:26:34 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205031026.q43AQYFi032363@svn.freebsd.org> From: Michael Tuexen Date: Thu, 3 May 2012 10:26:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234951 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 10:26:34 -0000 Author: tuexen Date: Thu May 3 10:26:33 2012 New Revision: 234951 URL: http://svn.freebsd.org/changeset/base/234951 Log: Fix another RFC 6458 issue. Spotted by Irene Ruengeler. MFC after: 3 days Modified: head/sys/netinet/sctp_output.c head/sys/netinet/sctp_uio.h Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Thu May 3 09:58:36 2012 (r234950) +++ head/sys/netinet/sctp_output.c Thu May 3 10:26:33 2012 (r234951) @@ -3430,7 +3430,7 @@ sctp_find_cmsg(int c_type, void *data, s } m_copydata(control, at + CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_authinfo), (caddr_t)&authinfo); sndrcvinfo->sinfo_keynumber_valid = 1; - sndrcvinfo->sinfo_keynumber = authinfo.auth_keyid; + sndrcvinfo->sinfo_keynumber = authinfo.auth_keynumber; break; default: return (found); Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Thu May 3 09:58:36 2012 (r234950) +++ head/sys/netinet/sctp_uio.h Thu May 3 10:26:33 2012 (r234951) @@ -169,7 +169,7 @@ struct sctp_default_prinfo { }; struct sctp_authinfo { - uint16_t auth_keyid; + uint16_t auth_keynumber; }; struct sctp_rcvinfo { From owner-svn-src-head@FreeBSD.ORG Thu May 3 10:38:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46331106564A; Thu, 3 May 2012 10:38:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30C618FC16; Thu, 3 May 2012 10:38:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43Ac3Qx032782; Thu, 3 May 2012 10:38:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Ac2eZ032779; Thu, 3 May 2012 10:38:02 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205031038.q43Ac2eZ032779@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 3 May 2012 10:38:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 10:38:03 -0000 Author: kib Date: Thu May 3 10:38:02 2012 New Revision: 234952 URL: http://svn.freebsd.org/changeset/base/234952 Log: When callout_reset_on() cannot immediately migrate a callout since it is running on other cpu, the CALLOUT_PENDING flag is temporarily cleared. Then, callout_stop() on this, in fact active, callout fails because CALLOUT_PENDING is not set, and callout_stop() returns 0. Now, in sleepq_check_timeout(), the failed callout_stop() causes the sleepq code to execute mi_switch() without even setting the wmesg, since the switch-out is supposed to be transient. In fact, the thread is put off the CPU for full timeout interval, instead of being put on runq immediately. Until timeout fires, the process is unkillable for obvious reasons. Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION flag. The flag is cleared by callout_stop_safe() when the function detects a migration, besides returning the success. The softclock() rechecks the flag for migrating callout and cancels its execution if the flag was cleared meantime. PR: misc/166340 Reported, debugging traces provided and tested by: Christian Esken Reviewed by: avg, jhb MFC after: 1 week Modified: head/sys/kern/kern_timeout.c head/sys/sys/callout.h Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Thu May 3 10:26:33 2012 (r234951) +++ head/sys/kern/kern_timeout.c Thu May 3 10:38:02 2012 (r234952) @@ -645,6 +645,32 @@ softclock(void *arg) cc_cme_cleanup(cc); /* + * Handle deferred callout stops + */ + if ((c->c_flags & CALLOUT_DFRMIGRATION) + == 0) { + CTR3(KTR_CALLOUT, + "deferred cancelled %p func %p arg %p", + c, new_func, new_arg); + if (cc->cc_next == c) { + cc->cc_next = + TAILQ_NEXT(c, + c_links.tqe); + } + if (c->c_flags & + CALLOUT_LOCAL_ALLOC) { + c->c_func = NULL; + SLIST_INSERT_HEAD( + &cc->cc_callfree, c, + c_links.sle); + } + goto nextc; + } else { + c->c_flags &= ~ + CALLOUT_DFRMIGRATION; + } + + /* * It should be assert here that the * callout is not destroyed but that * is not easy. @@ -659,6 +685,9 @@ softclock(void *arg) panic("migration should not happen"); #endif } +#ifdef SMP +nextc: +#endif steps = 0; c = cc->cc_next; } @@ -814,6 +843,7 @@ callout_reset_on(struct callout *c, int cc->cc_migration_ticks = to_ticks; cc->cc_migration_func = ftn; cc->cc_migration_arg = arg; + c->c_flags |= CALLOUT_DFRMIGRATION; CTR5(KTR_CALLOUT, "migration of %p func %p arg %p in %d to %u deferred", c, c->c_func, c->c_arg, to_ticks, cpu); @@ -984,6 +1014,12 @@ again: CC_UNLOCK(cc); KASSERT(!sq_locked, ("sleepqueue chain locked")); return (1); + } else if ((c->c_flags & CALLOUT_DFRMIGRATION) != 0) { + c->c_flags &= ~CALLOUT_DFRMIGRATION; + CTR3(KTR_CALLOUT, "postponing stop %p func %p arg %p", + c, c->c_func, c->c_arg); + CC_UNLOCK(cc); + return (1); } CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); Modified: head/sys/sys/callout.h ============================================================================== --- head/sys/sys/callout.h Thu May 3 10:26:33 2012 (r234951) +++ head/sys/sys/callout.h Thu May 3 10:38:02 2012 (r234952) @@ -46,6 +46,7 @@ #define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */ #define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */ #define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */ +#define CALLOUT_DFRMIGRATION 0x0040 /* callout in deferred migration mode */ struct callout_handle { struct callout *callout; From owner-svn-src-head@FreeBSD.ORG Thu May 3 11:02:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 15E051065672; Thu, 3 May 2012 11:02:11 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id DD6308FC14; Thu, 3 May 2012 11:02:09 +0000 (UTC) Received: by lagv3 with SMTP id v3so1572011lag.13 for ; Thu, 03 May 2012 04:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=26KrrRFA9EmtBrBwW8+aWzefPagZB56LJTRIECY+0XM=; b=uRIXmDP+RqCWPyASXh6zADRaYClvzfMwnV2v8+r28+BXEOrtaPcsfdkj34IXsx1kTV ssrL5ejCfQgKpIcT4dhk1RwZGXV70Xyhe9Gq3xjDolcM4HQf6CKsYpqLdeJmwH+PWczW F03KuCMxPIs5R8zCaeGeXpeIz8/RV7mFJkRliGvolHtJ9PUbtKbICI5zK/soTR0i27ZP PvtTLje415I5skGs2LP2Tw453Mm/od7L0MQoMso6CG+dYj5i0/KWIjiLQi5HIZJStvza WXMKYy7V0K2L8VoeEW6daBoMzpZRl3zl3H985/CmzQKwlBRGZOfV11jxMk7ymi9nUODR EkQw== MIME-Version: 1.0 Received: by 10.112.88.66 with SMTP id be2mr847298lbb.36.1336042928518; Thu, 03 May 2012 04:02:08 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 04:02:08 -0700 (PDT) In-Reply-To: <201205031038.q43Ac2eZ032779@svn.freebsd.org> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> Date: Thu, 3 May 2012 12:02:08 +0100 X-Google-Sender-Auth: 2MZjywyNJHk4hlneXs6srWcIfjc Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 11:02:11 -0000 2012/5/3, Konstantin Belousov : > Author: kib > Date: Thu May 3 10:38:02 2012 > New Revision: 234952 > URL: http://svn.freebsd.org/changeset/base/234952 > > Log: > When callout_reset_on() cannot immediately migrate a callout since it > is running on other cpu, the CALLOUT_PENDING flag is temporarily > cleared. Then, callout_stop() on this, in fact active, callout fails > because CALLOUT_PENDING is not set, and callout_stop() returns 0. > > Now, in sleepq_check_timeout(), the failed callout_stop() causes the > sleepq code to execute mi_switch() without even setting the wmesg, > since the switch-out is supposed to be transient. In fact, the thread > is put off the CPU for full timeout interval, instead of being put on > runq immediately. Until timeout fires, the process is unkillable for > obvious reasons. > > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION > flag. The flag is cleared by callout_stop_safe() when the function > detects a migration, besides returning the success. The softclock() > rechecks the flag for migrating callout and cancels its execution if > the flag was cleared meantime. Can you please clarify why you cannot simply drop the deferred migration in the case !CALLOUT_PENDING in callout_stop_safe()? Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-svn-src-head@FreeBSD.ORG Thu May 3 11:49:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A57C31065674; Thu, 3 May 2012 11:49:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 200E08FC17; Thu, 3 May 2012 11:49:21 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43BnEPQ082065; Thu, 3 May 2012 14:49:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q43BnD7U026953; Thu, 3 May 2012 14:49:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43BnDv0026952; Thu, 3 May 2012 14:49:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 May 2012 14:49:13 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VSonL41MObbAuehL" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 11:49:22 -0000 --VSonL41MObbAuehL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > 2012/5/3, Konstantin Belousov : > > Author: kib > > Date: Thu May 3 10:38:02 2012 > > New Revision: 234952 > > URL: http://svn.freebsd.org/changeset/base/234952 > > > > Log: > > When callout_reset_on() cannot immediately migrate a callout since it > > is running on other cpu, the CALLOUT_PENDING flag is temporarily > > cleared. Then, callout_stop() on this, in fact active, callout fails > > because CALLOUT_PENDING is not set, and callout_stop() returns 0. > > > > Now, in sleepq_check_timeout(), the failed callout_stop() causes the > > sleepq code to execute mi_switch() without even setting the wmesg, > > since the switch-out is supposed to be transient. In fact, the thread > > is put off the CPU for full timeout interval, instead of being put on > > runq immediately. Until timeout fires, the process is unkillable for > > obvious reasons. > > > > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION > > flag. The flag is cleared by callout_stop_safe() when the function > > detects a migration, besides returning the success. The softclock() > > rechecks the flag for migrating callout and cancels its execution if > > the flag was cleared meantime. >=20 > Can you please clarify why you cannot simply drop the deferred > migration in the case !CALLOUT_PENDING in callout_stop_safe()? I probably can, I think I went with the route of committed patch because it is slightly less work. Also, the comment in the while() loop suggested me to rely on softclock. --VSonL41MObbAuehL Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+icLkACgkQC3+MBN1Mb4ifBgCguBFmr3XD/vfD28mhzWhtEXC0 3toAoMDSGc/ElSj2X5E+Y1QGocG/Gd1a =NClt -----END PGP SIGNATURE----- --VSonL41MObbAuehL-- From owner-svn-src-head@FreeBSD.ORG Thu May 3 13:08:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4CA84106566C; Thu, 3 May 2012 13:08:12 +0000 (UTC) (envelope-from bjk@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3696C8FC08; Thu, 3 May 2012 13:08:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43D8CHk039905; Thu, 3 May 2012 13:08:12 GMT (envelope-from bjk@svn.freebsd.org) Received: (from bjk@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43D8CCq039903; Thu, 3 May 2012 13:08:12 GMT (envelope-from bjk@svn.freebsd.org) Message-Id: <201205031308.q43D8CCq039903@svn.freebsd.org> From: Benjamin Kaduk Date: Thu, 3 May 2012 13:08:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234953 - head/share/man/man4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:08:12 -0000 Author: bjk (doc committer) Date: Thu May 3 13:08:11 2012 New Revision: 234953 URL: http://svn.freebsd.org/changeset/base/234953 Log: Grammar and markup fixes. PR: docs/159854 Approved by: hrs (mentor) Modified: head/share/man/man4/carp.4 Modified: head/share/man/man4/carp.4 ============================================================================== --- head/share/man/man4/carp.4 Thu May 3 10:38:02 2012 (r234952) +++ head/share/man/man4/carp.4 Thu May 3 13:08:11 2012 (r234953) @@ -42,8 +42,8 @@ addresses are always available. .Pp To use .Nm , -the administrator needs to configure at minimum a common virtual host ID -(vhid) and attach at least one IP address to this vhid on each machine which +the administrator needs to configure at a minimum a common virtual host ID +(vhid), and attach at least one IP address to this vhid on each machine which is to take part in the virtual group. Additional parameters can also be set on a per-vhid basis: .Cm advbase @@ -72,13 +72,13 @@ Both and .Cm advskew are put inside CARP advertisements. -These configurations can be done using +These values can be configured using .Xr ifconfig 8 , or through the .Dv SIOCSVH .Xr ioctl 2 . .Pp -CARP virtual hosts can be configured on multicast capable interfaces: Ethernet, +CARP virtual hosts can be configured on multicast-capable interfaces: Ethernet, layer 2 VLAN, FDDI and Token Ring. An arbitrary number of virtual host IDs can be configured on an interface. An arbitrary number of IPv4 or IPv6 addresses can be attached to a particular @@ -91,7 +91,7 @@ elections independently. .Pp Additionally, there are a number of global parameters which can be set using .Xr sysctl 8 : -.Bl -tag -width ".Va net.inet.carp.preempt" +.Bl -tag -width ".Va net.inet.carp.ifdown_demotion_factor" .It Va net.inet.carp.allow Accept incoming .Nm @@ -103,14 +103,17 @@ When enabled, a vhid in a backup state w is announcing itself with a lower advskew. Disabled by default. .It Va net.inet.carp.log -Value of 0 disables any logging. -Value of 1 enables logging state changes of +Determines what events relating to +.Nm +interfaces are logged. +A value of 0 disables any logging. +A value of 1 enables logging state changes of .Nm vhids. Values above 1 enable logging of bad .Nm packets. -Default value is 1. +The default value is 1. .It Va net.inet.carp.demotion This value shows current level of CARP demotion. The value is added to the actual advskew sent in announcements for @@ -123,44 +126,48 @@ running a vhid goes down, or while the .Xr pfsync 4 interface is not synchronized. The demotion value is writable, so that user may alter it -depending on some external conditions, for example on status of some +depending on some external conditions, for example on the status of some daemon utility. -However, altering the value should be performed with care, do +However, altering the value should be performed with care, so as to not conflict with subsystems that adjust demotion factor automatically: .Nm and .Xr pfsync 4 . .It Va net.inet.carp.ifdown_demotion_factor -Value added to +This value is added to .Va net.inet.carp.demotion -when interface running a vhid goes down. -Default value is 240 (maximum advskew value). +when an interface running a vhid goes down. +The default value is 240 (the maximum advskew value). .It Va net.inet.carp.senderr_demotion_factor -Value added to +This value is added to .Va net.inet.carp.demotion when .Nm experiences errors sending its announcements. -Default value is 240 (maximum advskew value). +The default value is 240 (the maximum advskew value). .El .\".Sh ARP level load balancing -.\"The +.\"A .\".Nm -.\"has limited abilities for load balancing the incoming connections -.\"between hosts in Ethernet network. -.\"For load balancing operation, one needs several CARP interfaces that +.\"interface has limited abilities for load balancing incoming connections +.\"between hosts in an Ethernet network. +.\"For load-balancing operation, one needs several CARP interfaces that .\"are configured to the same IP address, but to a different vhids. .\"Once an ARP request is received, the CARP protocol will use a hashing .\"function against the source IP address in the ARP request to determine -.\"which vhid should this request belong to. -.\"If the corresponding CARP interface is in master state, the ARP request -.\"will be replied, otherwise it will be ignored. +.\"which vhid the request will be assigned to. +.\"If the corresponding CARP interface is the current +.\"master interface, a reply will +.\"be sent to the ARP request; +.\"otherwise it will be ignored. .\"See the .\".Sx EXAMPLES .\"section for a practical example of load balancing. .\".Pp -.\"The ARP load balancing has some limitations. +.\"The ARP load balancing implemented in +.\".Nm +.\"has some limitations. .\"First, ARP balancing only works on the local network segment. .\"It cannot balance traffic that crosses a router, because the .\"router itself will always be balanced to the same virtual host. @@ -170,10 +177,11 @@ Default value is 240 (maximum advskew va .\"is dangerous, because this creates a race condition between .\"balanced routers and a host they are serving. .\"Imagine an incoming packet creating state on the first router, being -.\"forwarded to its destination, and destination replying faster +.\"forwarded to its destination, and the destination replying faster .\"than the state information is packed and synced with the second router. .\"If the reply would be load balanced to second router, it will be -.\"dropped due to no state. +.\"dropped since the second router has not yet received information about +.\"the connection state. .Sh STATE CHANGE NOTIFICATIONS Sometimes it is useful to get notified about .Nm @@ -183,11 +191,12 @@ This can be accomplished by using hooks. Master/slave events are signalled under system .Dv CARP . -Subsystem specifies vhid and name of interface, where event occurred. -Type of the message displays new state of vhid. +The subsystem specifies the vhid and name of the interface where +the master/slave event occurred. +The type of the message displays the new state of the vhid. Please see .Xr devd.conf 5 -and +and the .Sx EXAMPLES section for more information. .Sh EXAMPLES @@ -195,8 +204,8 @@ For firewalls and routers with multiple failover all of the addresses running .Nm together, when one of the physical interfaces goes down. -This is achieved by the preempt option. -Enable it on both host A and B: +This is achieved by the use of the preempt option. +Enable it on both hosts A and B: .Pp .Dl sysctl net.inet.carp.preempt=1 .Pp @@ -295,7 +304,6 @@ The device was imported into .Fx 5.4 . In -.Fx 10.0 -the +.Fx 10.0 , .Nm was significantly rewritten, and is no longer a pseudo-interface. From owner-svn-src-head@FreeBSD.ORG Thu May 3 13:14:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37E89106564A; Thu, 3 May 2012 13:14:23 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 761638FC14; Thu, 3 May 2012 13:14:22 +0000 (UTC) Received: by vbmv11 with SMTP id v11so1650558vbm.13 for ; Thu, 03 May 2012 06:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=7uzJ8xgsPVtntvkCdfcB7L4yRXAV3MCDruYTzC4GA8M=; b=bxc02wTT8tCWdOzWNZtqbtG8hMp041pGRC3olzbk6S82TPhglR6v5EHD9CXDIoaGl0 8A48h8R9/gdF1eZCtS2P3ZNbTcoabFLR0iKpEqxuYCB3G8GDip7zM1doZ0lExkQ1MlsL C//6Pe0VXe16iJ+Z71J2tshe31az/wUkNNCtclB94mpunFyVe22Q4YStvSCgpefD9PdW q0Uy7QDw0A1/IvTwxcX2gI9/dR6SLMlPoxOEKlep9oNf4TiafUEPKKNayglDpUMX877y gfxGcI/qCvaaBrWlK5vK4aOzOLmSIbNdhd9joSFDlUGGb/swNj5MyknhlLUwPQJNRUM0 xUdA== MIME-Version: 1.0 Received: by 10.52.23.70 with SMTP id k6mr979335vdf.86.1336050861664; Thu, 03 May 2012 06:14:21 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.220.38.72 with HTTP; Thu, 3 May 2012 06:14:20 -0700 (PDT) In-Reply-To: <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 14:14:20 +0100 X-Google-Sender-Auth: wCNjRFQNGd-4CgDcioS5uUctlTc Message-ID: From: Attilio Rao To: Konstantin Belousov , christian.esken@trivago.com Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:14:23 -0000 2012/5/3, Konstantin Belousov : > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> 2012/5/3, Konstantin Belousov : >> > Author: kib >> > Date: Thu May 3 10:38:02 2012 >> > New Revision: 234952 >> > URL: http://svn.freebsd.org/changeset/base/234952 >> > >> > Log: >> > When callout_reset_on() cannot immediately migrate a callout since it >> > is running on other cpu, the CALLOUT_PENDING flag is temporarily >> > cleared. Then, callout_stop() on this, in fact active, callout fails >> > because CALLOUT_PENDING is not set, and callout_stop() returns 0. >> > >> > Now, in sleepq_check_timeout(), the failed callout_stop() causes the >> > sleepq code to execute mi_switch() without even setting the wmesg, >> > since the switch-out is supposed to be transient. In fact, the thread >> > is put off the CPU for full timeout interval, instead of being put on >> > runq immediately. Until timeout fires, the process is unkillable for >> > obvious reasons. >> > >> > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATION >> > flag. The flag is cleared by callout_stop_safe() when the function >> > detects a migration, besides returning the success. The softclock() >> > rechecks the flag for migrating callout and cancels its execution if >> > the flag was cleared meantime. >> >> Can you please clarify why you cannot simply drop the deferred >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > > I probably can, I think I went with the route of committed patch > because it is slightly less work. Also, the comment in the while() > loop suggested me to rely on softclock. I don't think this is more work at all, the attached patch (pre-r234952, untested) should address it properly in few than 10 lines: http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch without the need to add further flags and re-using existing mechanisms. Attilio -- Peace can only be achieved by understanding - A. Einstein From owner-svn-src-head@FreeBSD.ORG Thu May 3 13:27:27 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A1A0106564A; Thu, 3 May 2012 13:27:27 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 0019D8FC16; Thu, 3 May 2012 13:27:26 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43DRGQZ098646; Thu, 3 May 2012 16:27:16 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q43DRFhA039663; Thu, 3 May 2012 16:27:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43DRFHK039662; Thu, 3 May 2012 16:27:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 May 2012 16:27:15 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503132715.GN2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="v0lslBALPq2/Zk2u" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 13:27:27 -0000 --v0lslBALPq2/Zk2u Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: > 2012/5/3, Konstantin Belousov : > > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > >> 2012/5/3, Konstantin Belousov : > >> > Author: kib > >> > Date: Thu May 3 10:38:02 2012 > >> > New Revision: 234952 > >> > URL: http://svn.freebsd.org/changeset/base/234952 > >> > > >> > Log: > >> > When callout_reset_on() cannot immediately migrate a callout since= it > >> > is running on other cpu, the CALLOUT_PENDING flag is temporarily > >> > cleared. Then, callout_stop() on this, in fact active, callout fai= ls > >> > because CALLOUT_PENDING is not set, and callout_stop() returns 0. > >> > > >> > Now, in sleepq_check_timeout(), the failed callout_stop() causes t= he > >> > sleepq code to execute mi_switch() without even setting the wmesg, > >> > since the switch-out is supposed to be transient. In fact, the thr= ead > >> > is put off the CPU for full timeout interval, instead of being put= on > >> > runq immediately. Until timeout fires, the process is unkillable = for > >> > obvious reasons. > >> > > >> > Fix this by marking the migrating callouts with CALLOUT_DFRMIGRATI= ON > >> > flag. The flag is cleared by callout_stop_safe() when the function > >> > detects a migration, besides returning the success. The softclock() > >> > rechecks the flag for migrating callout and cancels its execution = if > >> > the flag was cleared meantime. > >> > >> Can you please clarify why you cannot simply drop the deferred > >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > > > > I probably can, I think I went with the route of committed patch > > because it is slightly less work. Also, the comment in the while() > > loop suggested me to rely on softclock. >=20 > I don't think this is more work at all, the attached patch > (pre-r234952, untested) should address it properly in few than 10 > lines: > http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >=20 > without the need to add further flags and re-using existing mechanisms. (cc->cc_curr !=3D c) is not the case which caused the issue. It might be needed to treatened this way, but the reported case is opposite. --v0lslBALPq2/Zk2u Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+ih7MACgkQC3+MBN1Mb4gtdACfUK1QNh57ZBpu2xpbPOIiuSEZ 8hEAn1EF1Yy77YYiz+TVmihpyg9JpZNj =uXBb -----END PGP SIGNATURE----- --v0lslBALPq2/Zk2u-- From owner-svn-src-head@FreeBSD.ORG Thu May 3 15:25:14 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 087281065674; Thu, 3 May 2012 15:25:14 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E334E8FC1D; Thu, 3 May 2012 15:25:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43FPDCT048845; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FPDbE048833; Thu, 3 May 2012 15:25:13 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201205031525.q43FPDbE048833@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 3 May 2012 15:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234954 - head/crypto/openssl/crypto head/crypto/openssl/crypto/asn1 head/crypto/openssl/crypto/buffer head/crypto/openssl/crypto/pkcs7 head/crypto/openssl/crypto/x509v3 head/crypto/ope... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:25:14 -0000 Author: bz Date: Thu May 3 15:25:11 2012 New Revision: 234954 URL: http://svn.freebsd.org/changeset/base/234954 Log: Fix multiple OpenSSL vulnerabilities. Security: CVE-2011-4576, CVE-2011-4619, CVE-2011-4109 Security: CVE-2012-0884, CVE-2012-2110 Security: FreeBSD-SA-12:01.openssl Approved by: so (bz,simon) Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c head/crypto/openssl/crypto/buffer/buffer.c head/crypto/openssl/crypto/mem.c head/crypto/openssl/crypto/pkcs7/pk7_doit.c head/crypto/openssl/crypto/x509v3/pcy_map.c head/crypto/openssl/crypto/x509v3/pcy_tree.c head/crypto/openssl/ssl/s3_enc.c head/crypto/openssl/ssl/s3_srvr.c head/crypto/openssl/ssl/ssl.h head/crypto/openssl/ssl/ssl3.h head/crypto/openssl/ssl/ssl_err.c Changes in other areas also in this revision: Modified: releng/7.4/UPDATING releng/7.4/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/7.4/crypto/openssl/crypto/buffer/buffer.c releng/7.4/crypto/openssl/crypto/mem.c releng/7.4/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_map.c releng/7.4/crypto/openssl/crypto/x509v3/pcy_tree.c releng/7.4/crypto/openssl/ssl/s3_enc.c releng/7.4/crypto/openssl/ssl/s3_srvr.c releng/7.4/crypto/openssl/ssl/ssl.h releng/7.4/crypto/openssl/ssl/ssl3.h releng/7.4/crypto/openssl/ssl/ssl_err.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.1/crypto/openssl/crypto/buffer/buffer.c releng/8.1/crypto/openssl/crypto/mem.c releng/8.1/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.1/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.1/crypto/openssl/ssl/s3_enc.c releng/8.1/crypto/openssl/ssl/s3_srvr.c releng/8.1/crypto/openssl/ssl/ssl.h releng/8.1/crypto/openssl/ssl/ssl3.h releng/8.1/crypto/openssl/ssl/ssl_err.c releng/8.1/sys/conf/newvers.sh releng/8.2/UPDATING releng/8.2/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.2/crypto/openssl/crypto/buffer/buffer.c releng/8.2/crypto/openssl/crypto/mem.c releng/8.2/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.2/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.2/crypto/openssl/ssl/s3_enc.c releng/8.2/crypto/openssl/ssl/s3_srvr.c releng/8.2/crypto/openssl/ssl/ssl.h releng/8.2/crypto/openssl/ssl/ssl3.h releng/8.2/crypto/openssl/ssl/ssl_err.c releng/8.2/sys/conf/newvers.sh releng/8.3/UPDATING releng/8.3/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/8.3/crypto/openssl/crypto/buffer/buffer.c releng/8.3/crypto/openssl/crypto/mem.c releng/8.3/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_map.c releng/8.3/crypto/openssl/crypto/x509v3/pcy_tree.c releng/8.3/crypto/openssl/ssl/s3_enc.c releng/8.3/crypto/openssl/ssl/s3_srvr.c releng/8.3/crypto/openssl/ssl/ssl.h releng/8.3/crypto/openssl/ssl/ssl3.h releng/8.3/crypto/openssl/ssl/ssl_err.c releng/8.3/sys/conf/newvers.sh releng/9.0/UPDATING releng/9.0/crypto/openssl/crypto/asn1/a_d2i_fp.c releng/9.0/crypto/openssl/crypto/buffer/buffer.c releng/9.0/crypto/openssl/crypto/mem.c releng/9.0/crypto/openssl/crypto/pkcs7/pk7_doit.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_map.c releng/9.0/crypto/openssl/crypto/x509v3/pcy_tree.c releng/9.0/crypto/openssl/ssl/s3_enc.c releng/9.0/crypto/openssl/ssl/s3_srvr.c releng/9.0/crypto/openssl/ssl/ssl.h releng/9.0/crypto/openssl/ssl/ssl3.h releng/9.0/crypto/openssl/ssl/ssl_err.c releng/9.0/sys/conf/newvers.sh stable/7/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/7/crypto/openssl/crypto/buffer/buffer.c stable/7/crypto/openssl/crypto/mem.c stable/7/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/7/crypto/openssl/crypto/x509v3/pcy_map.c stable/7/crypto/openssl/crypto/x509v3/pcy_tree.c stable/7/crypto/openssl/ssl/s3_enc.c stable/7/crypto/openssl/ssl/s3_srvr.c stable/7/crypto/openssl/ssl/ssl.h stable/7/crypto/openssl/ssl/ssl3.h stable/7/crypto/openssl/ssl/ssl_err.c stable/8/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/8/crypto/openssl/crypto/buffer/buffer.c stable/8/crypto/openssl/crypto/mem.c stable/8/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/8/crypto/openssl/crypto/x509v3/pcy_map.c stable/8/crypto/openssl/crypto/x509v3/pcy_tree.c stable/8/crypto/openssl/ssl/s3_enc.c stable/8/crypto/openssl/ssl/s3_srvr.c stable/8/crypto/openssl/ssl/ssl.h stable/8/crypto/openssl/ssl/ssl3.h stable/8/crypto/openssl/ssl/ssl_err.c stable/9/crypto/openssl/crypto/asn1/a_d2i_fp.c stable/9/crypto/openssl/crypto/buffer/buffer.c stable/9/crypto/openssl/crypto/mem.c stable/9/crypto/openssl/crypto/pkcs7/pk7_doit.c stable/9/crypto/openssl/crypto/x509v3/pcy_map.c stable/9/crypto/openssl/crypto/x509v3/pcy_tree.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_srvr.c stable/9/crypto/openssl/ssl/ssl.h stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_err.c Modified: head/crypto/openssl/crypto/asn1/a_d2i_fp.c ============================================================================== --- head/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/asn1/a_d2i_fp.c Thu May 3 15:25:11 2012 (r234954) @@ -57,6 +57,7 @@ */ #include +#include #include "cryptlib.h" #include #include @@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BU BUF_MEM *b; unsigned char *p; int i; - int ret=-1; ASN1_const_CTX c; - int want=HEADER_SIZE; + size_t want=HEADER_SIZE; int eos=0; -#if defined(__GNUC__) && defined(__ia64) - /* pathetic compiler bug in all known versions as of Nov. 2002 */ - long off=0; -#else - int off=0; -#endif - int len=0; + size_t off=0; + size_t len=0; b=BUF_MEM_new(); if (b == NULL) @@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BU { want-=(len-off); - if (!BUF_MEM_grow_clean(b,len+want)) + if (len + want < len || !BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; @@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BU goto err; } if (i > 0) + { + if (len+i < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } len+=i; + } } /* else data already loaded */ @@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BU { /* no data body so go round again */ eos++; + if (eos < 0) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG); + goto err; + } want=HEADER_SIZE; } else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) @@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BU else { /* suck in c.slen bytes of data */ - want=(int)c.slen; + want=c.slen; if (want > (len-off)) { want-=(len-off); + if (want > INT_MAX /* BIO_read takes an int length */ || + len+want < len) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } if (!BUF_MEM_grow_clean(b,len+want)) { ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE); @@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BU ASN1_R_NOT_ENOUGH_DATA); goto err; } + /* This can't overflow because + * |len+want| didn't overflow. */ len+=i; - want -= i; + want-=i; } } - off+=(int)c.slen; + if (off + c.slen < off) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + off+=c.slen; if (eos <= 0) { break; @@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BU } } + if (off > INT_MAX) + { + ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG); + goto err; + } + *pb = b; return off; err: if (b != NULL) BUF_MEM_free(b); - return(ret); + return -1; } Modified: head/crypto/openssl/crypto/buffer/buffer.c ============================================================================== --- head/crypto/openssl/crypto/buffer/buffer.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/buffer/buffer.c Thu May 3 15:25:11 2012 (r234954) @@ -60,6 +60,11 @@ #include "cryptlib.h" #include +/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That + * function is applied in several functions in this file and this limit ensures + * that the result fits in an int. */ +#define LIMIT_BEFORE_EXPANSION 0x5ffffffc + BUF_MEM *BUF_MEM_new(void) { BUF_MEM *ret; @@ -94,6 +99,11 @@ int BUF_MEM_grow(BUF_MEM *str, int len) char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { str->length=len; @@ -105,6 +115,12 @@ int BUF_MEM_grow(BUF_MEM *str, int len) str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); @@ -130,6 +146,11 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int char *ret; unsigned int n; + if (len < 0) + { + BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE); + return 0; + } if (str->length >= len) { memset(&str->data[len],0,str->length-len); @@ -142,6 +163,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int str->length=len; return(len); } + /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ + if (len > LIMIT_BEFORE_EXPANSION) + { + BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE); + return 0; + } n=(len+3)/3*4; if (str->data == NULL) ret=OPENSSL_malloc(n); Modified: head/crypto/openssl/crypto/mem.c ============================================================================== --- head/crypto/openssl/crypto/mem.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/mem.c Thu May 3 15:25:11 2012 (r234954) @@ -372,6 +372,10 @@ void *CRYPTO_realloc_clean(void *str, in if (num <= 0) return NULL; + /* We don't support shrinking the buffer. Note the memcpy that copies + * |old_len| bytes to the new buffer, below. */ + if (num < old_len) return NULL; + if (realloc_debug_func != NULL) realloc_debug_func(str, NULL, num, file, line, 0); ret=malloc_ex_func(num,file,line); Modified: head/crypto/openssl/crypto/pkcs7/pk7_doit.c ============================================================================== --- head/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/pkcs7/pk7_doit.c Thu May 3 15:25:11 2012 (r234954) @@ -420,6 +420,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE int max; X509_OBJECT ret; #endif + unsigned char *tkey = NULL; + int tkeylen; int jj; if ((etmp=BIO_new(BIO_f_cipher())) == NULL) @@ -461,36 +463,42 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE if (pcert == NULL) { + /* Temporary storage in case EVP_PKEY_decrypt + * overwrites output buffer on error. + */ + unsigned char *tmp2; + tmp2 = OPENSSL_malloc(jj); + if (!tmp2) + goto err; + jj = -1; + /* Always attempt to decrypt all cases to avoid + * leaking timing information about a successful + * decrypt. + */ for (i=0; ienc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj > 0) - break; + if (tret > 0) + { + memcpy(tmp, tmp2, tret); + OPENSSL_cleanse(tmp2, tret); + jj = tret; + } ERR_clear_error(); - ri = NULL; - } - if (ri == NULL) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_NO_RECIPIENT_MATCHES_KEY); - goto err; } + OPENSSL_free(tmp2); } else { jj=EVP_PKEY_decrypt(tmp, M_ASN1_STRING_data(ri->enc_key), M_ASN1_STRING_length(ri->enc_key), pkey); - if (jj <= 0) - { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - ERR_R_EVP_LIB); - goto err; - } + ERR_clear_error(); } evp_ctx=NULL; @@ -499,24 +507,49 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE goto err; if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0) goto err; + /* Generate random key to counter MMA */ + tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx); + tkey = OPENSSL_malloc(tkeylen); + if (!tkey) + goto err; + if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0) + goto err; + /* If we have no key use random key */ + if (jj <= 0) + { + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; + } - if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) { + if (jj != tkeylen) { /* Some S/MIME clients don't use the same key * and effective key length. The key length is * determined by the size of the decrypted RSA key. */ if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, jj)) { - PKCS7err(PKCS7_F_PKCS7_DATADECODE, - PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH); - goto err; + /* As MMA defence use random key instead */ + OPENSSL_cleanse(tmp, jj); + OPENSSL_free(tmp); + jj = tkeylen; + tmp = tkey; + tkey = NULL; } } + ERR_clear_error(); if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,tmp,NULL,0) <= 0) goto err; OPENSSL_cleanse(tmp,jj); + if (tkey) + { + OPENSSL_cleanse(tkey, tkeylen); + OPENSSL_free(tkey); + } + if (out == NULL) out=etmp; else Modified: head/crypto/openssl/crypto/x509v3/pcy_map.c ============================================================================== --- head/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/x509v3/pcy_map.c Thu May 3 15:25:11 2012 (r234954) @@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF static void policy_map_free(X509_POLICY_REF *map) { - if (map->subjectDomainPolicy) - ASN1_OBJECT_free(map->subjectDomainPolicy); OPENSSL_free(map); } @@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO { POLICY_MAPPING *map; X509_POLICY_REF *ref = NULL; + ASN1_OBJECT *subjectDomainPolicyRef; X509_POLICY_DATA *data; X509_POLICY_CACHE *cache = x->policy_cache; int i; @@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO if (!sk_ASN1_OBJECT_push(data->expected_policy_set, map->subjectDomainPolicy)) goto bad_mapping; + /* map->subjectDomainPolicy will be freed when + * cache->data is freed. Set it to NULL to avoid double-free. */ + subjectDomainPolicyRef = map->subjectDomainPolicy; + map->subjectDomainPolicy = NULL; ref = OPENSSL_malloc(sizeof(X509_POLICY_REF)); if (!ref) goto bad_mapping; - ref->subjectDomainPolicy = map->subjectDomainPolicy; - map->subjectDomainPolicy = NULL; + ref->subjectDomainPolicy = subjectDomainPolicyRef; ref->data = data; if (!sk_X509_POLICY_REF_push(cache->maps, ref)) Modified: head/crypto/openssl/crypto/x509v3/pcy_tree.c ============================================================================== --- head/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/crypto/x509v3/pcy_tree.c Thu May 3 15:25:11 2012 (r234954) @@ -612,6 +612,10 @@ int X509_policy_check(X509_POLICY_TREE * case 2: return 1; + /* Some internal error */ + case -1: + return -1; + /* Some internal error */ case 0: return 0; @@ -691,4 +695,3 @@ int X509_policy_check(X509_POLICY_TREE * return 0; } - Modified: head/crypto/openssl/ssl/s3_enc.c ============================================================================== --- head/crypto/openssl/ssl/s3_enc.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/s3_enc.c Thu May 3 15:25:11 2012 (r234954) @@ -479,6 +479,9 @@ int ssl3_enc(SSL *s, int send) /* we need to add 'i-1' padding bytes */ l+=i; + /* the last of these zero bytes will be overwritten + * with the padding length. */ + memset(&rec->input[rec->length], 0, i); rec->length+=i; rec->input[l-1]=(i-1); } Modified: head/crypto/openssl/ssl/s3_srvr.c ============================================================================== --- head/crypto/openssl/ssl/s3_srvr.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/s3_srvr.c Thu May 3 15:25:11 2012 (r234954) @@ -235,6 +235,7 @@ int ssl3_accept(SSL *s) } s->init_num=0; + s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE; if (s->state != SSL_ST_RENEGOTIATE) { @@ -697,6 +698,14 @@ int ssl3_check_client_hello(SSL *s) int ok; long n; + /* We only allow the client to restart the handshake once per + * negotiation. */ + if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE) + { + SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS); + return -1; + } + /* this function is called when we really expect a Certificate message, * so permit appropriate message length */ n=s->method->ssl_get_message(s, @@ -725,6 +734,7 @@ int ssl3_check_client_hello(SSL *s) s->s3->tmp.ecdh = NULL; } #endif + s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE; return 2; } return 1; Modified: head/crypto/openssl/ssl/ssl.h ============================================================================== --- head/crypto/openssl/ssl/ssl.h Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/ssl.h Thu May 3 15:25:11 2012 (r234954) @@ -1739,6 +1739,7 @@ void ERR_load_SSL_strings(void); #define SSL_F_SSL3_CALLBACK_CTRL 233 #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 +#define SSL_F_SSL3_CHECK_CLIENT_HELLO 292 #define SSL_F_SSL3_CLIENT_HELLO 131 #define SSL_F_SSL3_CONNECT 132 #define SSL_F_SSL3_CTRL 213 @@ -1974,6 +1975,7 @@ void ERR_load_SSL_strings(void); #define SSL_R_MISSING_TMP_RSA_KEY 172 #define SSL_R_MISSING_TMP_RSA_PKEY 173 #define SSL_R_MISSING_VERIFY_MESSAGE 174 +#define SSL_R_MULTIPLE_SGC_RESTARTS 325 #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 #define SSL_R_NO_CERTIFICATES_RETURNED 176 #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 Modified: head/crypto/openssl/ssl/ssl3.h ============================================================================== --- head/crypto/openssl/ssl/ssl3.h Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/ssl3.h Thu May 3 15:25:11 2012 (r234954) @@ -333,6 +333,17 @@ typedef struct ssl3_buffer_st #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 #define SSL3_FLAGS_POP_BUFFER 0x0004 #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 + +/* SSL3_FLAGS_SGC_RESTART_DONE is set when we + * restart a handshake because of MS SGC and so prevents us + * from restarting the handshake in a loop. It's reset on a + * renegotiation, so effectively limits the client to one restart + * per negotiation. This limits the possibility of a DDoS + * attack where the client handshakes in a loop using SGC to + * restart. Servers which permit renegotiation can still be + * effected, but we can't prevent that. + */ +#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040 typedef struct ssl3_state_st { Modified: head/crypto/openssl/ssl/ssl_err.c ============================================================================== --- head/crypto/openssl/ssl/ssl_err.c Thu May 3 13:08:11 2012 (r234953) +++ head/crypto/openssl/ssl/ssl_err.c Thu May 3 15:25:11 2012 (r234954) @@ -137,6 +137,7 @@ static ERR_STRING_DATA SSL_str_functs[]= {ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"}, {ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"}, {ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"}, +{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"}, {ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"}, {ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"}, @@ -375,6 +376,7 @@ static ERR_STRING_DATA SSL_str_reasons[] {ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"}, {ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"}, {ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"}, +{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"}, {ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"}, {ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"}, {ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"}, From owner-svn-src-head@FreeBSD.ORG Thu May 3 15:34:45 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B0AC1065670; Thu, 3 May 2012 15:34:45 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 45CA98FC17; Thu, 3 May 2012 15:34:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43FYjaA049206; Thu, 3 May 2012 15:34:45 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FYjIR049204; Thu, 3 May 2012 15:34:45 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031534.q43FYjIR049204@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 15:34:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234955 - head/tools/tools/netmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:34:45 -0000 Author: luigi Date: Thu May 3 15:34:44 2012 New Revision: 234955 URL: http://svn.freebsd.org/changeset/base/234955 Log: - correct a bug in pcap_dispatch(): a count of 0 means infinity. - in pcap_dispatch(), issue a prefetch on the buffer before the callback, this may save a little bit of time if the client is very fast. - in pcap_inject(), use a fast copy routine, which also helps saving a few nanoseconds with fast clients. Modified: head/tools/tools/netmap/pcap.c Modified: head/tools/tools/netmap/pcap.c ============================================================================== --- head/tools/tools/netmap/pcap.c Thu May 3 15:25:11 2012 (r234954) +++ head/tools/tools/netmap/pcap.c Thu May 3 15:34:44 2012 (r234955) @@ -49,6 +49,34 @@ int verbose = 0; __FUNCTION__, __LINE__, ##__VA_ARGS__); \ } while (0) +inline void prefetch (const void *x) +{ + __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x)); +} + +// XXX only for multiples of 64 bytes, non overlapped. +static inline void +pkt_copy(const void *_src, void *_dst, int l) +{ + const uint64_t *src = _src; + uint64_t *dst = _dst; +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + if (unlikely(l >= 1024)) { + bcopy(src, dst, l); + return; + } + for (; l > 0; l-=64) { + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + } +} /* * We redefine here a number of structures that are in pcap.h @@ -479,21 +507,21 @@ pcap_setfilter(__unused pcap_t *p, __unu int pcap_datalink(__unused pcap_t *p) { - D(""); + D("returns 1"); return 1; // ethernet } const char * pcap_datalink_val_to_name(int dlt) { - D("%d", dlt); + D("%d returns DLT_EN10MB", dlt); return "DLT_EN10MB"; } const char * pcap_datalink_val_to_description(int dlt) { - D("%d", dlt); + D("%d returns Ethernet link", dlt); return "Ethernet link"; } @@ -525,7 +553,8 @@ pcap_open_live(const char *device, __unu { struct my_ring *me; - D("request to open %s", device); + D("request to open %s snaplen %d promisc %d timeout %dms", + device, snaplen, promisc, to_ms); me = calloc(1, sizeof(*me)); if (me == NULL) { D("failed to allocate struct for %s", device); @@ -610,6 +639,8 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h u_int si; ND("cnt %d", cnt); + if (cnt == 0) + cnt = -1; /* scan all rings */ for (si = me->begin; si < me->end; si++) { struct netmap_ring *ring = NETMAP_RXRING(me->nifp, si); @@ -617,6 +648,10 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h if (ring->avail == 0) continue; me->hdr.ts = ring->ts; + /* + * XXX a proper prefetch should be done as + * prefetch(i); callback(i-1); ... + */ while ((cnt == -1 || cnt != got) && ring->avail > 0) { u_int i = ring->cur; u_int idx = ring->slot[i].buf_idx; @@ -626,6 +661,7 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h sleep(2); } u_char *buf = (u_char *)NETMAP_BUF(ring, idx); + prefetch(buf); me->hdr.len = me->hdr.caplen = ring->slot[i].len; // D("call %p len %d", p, me->hdr.len); callback(user, &me->hdr, buf); @@ -660,7 +696,7 @@ pcap_inject(pcap_t *p, const void *buf, } u_char *dst = (u_char *)NETMAP_BUF(ring, idx); ring->slot[i].len = size; - bcopy(buf, dst, size); + pkt_copy(buf, dst, size); ring->cur = NETMAP_RING_NEXT(ring, i); ring->avail--; // if (ring->avail == 0) ioctl(me->fd, NIOCTXSYNC, NULL); From owner-svn-src-head@FreeBSD.ORG Thu May 3 15:37:06 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A6C3106564A; Thu, 3 May 2012 15:37:06 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 53B128FC15; Thu, 3 May 2012 15:37:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43Fb6Sf049337; Thu, 3 May 2012 15:37:06 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Fb6Op049335; Thu, 3 May 2012 15:37:06 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031537.q43Fb6Op049335@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 15:37:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234956 - head/tools/tools/netmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:37:06 -0000 Author: luigi Date: Thu May 3 15:37:05 2012 New Revision: 234956 URL: http://svn.freebsd.org/changeset/base/234956 Log: - add code to run pkt-gen on top of libpcap so we can see the difference from a native API - add some testing options, such as conditional prefetching and packet copy. Modified: head/tools/tools/netmap/pkt-gen.c Modified: head/tools/tools/netmap/pkt-gen.c ============================================================================== --- head/tools/tools/netmap/pkt-gen.c Thu May 3 15:34:44 2012 (r234955) +++ head/tools/tools/netmap/pkt-gen.c Thu May 3 15:37:05 2012 (r234956) @@ -25,7 +25,7 @@ /* * $FreeBSD$ - * $Id: pkt-gen.c 10637 2012-02-24 16:36:25Z luigi $ + * $Id: pkt-gen.c 10967 2012-05-03 11:29:23Z luigi $ * * Example program to show how to build a multithreaded packet * source/sink using the netmap device. @@ -90,6 +90,36 @@ int verbose = 0; #define SKIP_PAYLOAD 1 /* do not check payload. */ +inline void prefetch (const void *x) +{ + __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x)); +} + +// XXX only for multiples of 32 bytes, non overlapped. +static inline void +pkt_copy(void *_src, void *_dst, int l) +{ + uint64_t *src = _src; + uint64_t *dst = _dst; +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) + if (unlikely(l >= 1024)) { + bcopy(src, dst, l); + return; + } + for (; l > 0; l-=64) { + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + } +} + + #if EXPERIMENTAL /* Wrapper around `rdtsc' to take reliable timestamps flushing the pipeline */ #define netmap_rdtsc(t) \ @@ -140,6 +170,11 @@ struct glob_arg { int npackets; /* total packets to send */ int nthreads; int cpus; + int options; /* testing */ +#define OPT_PREFETCH 1 +#define OPT_ACCESS 2 +#define OPT_COPY 4 +#define OPT_MEMCPY 8 int use_pcap; pcap_t *p; }; @@ -394,19 +429,35 @@ check_payload(char *p, int psize) */ static int send_packets(struct netmap_ring *ring, struct pkt *pkt, - int size, u_int count, int fill_all) + int size, u_int count, int options) { u_int sent, cur = ring->cur; if (ring->avail < count) count = ring->avail; +#if 0 + if (options & (OPT_COPY | OPT_PREFETCH) ) { + for (sent = 0; sent < count; sent++) { + struct netmap_slot *slot = &ring->slot[cur]; + char *p = NETMAP_BUF(ring, slot->buf_idx); + + prefetch(p); + cur = NETMAP_RING_NEXT(ring, cur); + } + cur = ring->cur; + } +#endif for (sent = 0; sent < count; sent++) { struct netmap_slot *slot = &ring->slot[cur]; char *p = NETMAP_BUF(ring, slot->buf_idx); - if (fill_all) + if (options & OPT_COPY) + pkt_copy(pkt, p, size); + else if (options & OPT_MEMCPY) memcpy(p, pkt, size); + else if (options & OPT_PREFETCH) + prefetch(p); slot->len = size; if (sent == count - 1) @@ -428,8 +479,8 @@ sender_body(void *data) struct netmap_if *nifp = targ->nifp; struct netmap_ring *txring; int i, n = targ->g->npackets / targ->g->nthreads, sent = 0; - int fill_all = 1; - + int options = targ->g->options | OPT_COPY; +D("start"); if (setaffinity(targ->thread, targ->affinity)) goto quit; /* setup poll(2) mechanism. */ @@ -444,9 +495,13 @@ sender_body(void *data) void *pkt = &targ->pkt; pcap_t *p = targ->g->p; - for (; sent < n; sent++) { - if (pcap_inject(p, pkt, size) == -1) - break; + for (i = 0; sent < n; i++) { + if (pcap_inject(p, pkt, size) != -1) + sent++; + if (i > 10000) { + targ->count = sent; + i = 0; + } } } else { while (sent < n) { @@ -461,8 +516,8 @@ sender_body(void *data) /* * scan our queues and send on those with room */ - if (sent > 100000) - fill_all = 0; + if (sent > 100000 && !(targ->g->options & OPT_COPY) ) + options &= ~OPT_COPY; for (i = targ->qfirst; i < targ->qlast; i++) { int m, limit = MIN(n - sent, targ->g->burst); @@ -470,12 +525,12 @@ sender_body(void *data) if (txring->avail == 0) continue; m = send_packets(txring, &targ->pkt, targ->g->pkt_size, - limit, fill_all); + limit, options); sent += m; targ->count = sent; } } - /* Tell the interface that we have new packets. */ + /* flush any remaining packets */ ioctl(fds[0].fd, NIOCTXSYNC, NULL); /* final part: wait all the TX queues to be empty. */ @@ -672,6 +727,7 @@ int main(int arc, char **argv) { int i, fd; + char pcap_errbuf[PCAP_ERRBUF_SIZE]; struct glob_arg g; @@ -696,12 +752,15 @@ main(int arc, char **argv) g.cpus = 1; while ( (ch = getopt(arc, argv, - "i:t:r:l:d:s:D:S:b:c:p:T:w:v")) != -1) { + "i:t:r:l:d:s:D:S:b:c:o:p:PT:w:v")) != -1) { switch(ch) { default: D("bad option %c %s", ch, optarg); usage(); break; + case 'o': + g.options = atoi(optarg); + break; case 'i': /* interface */ ifname = optarg; break; @@ -775,6 +834,26 @@ main(int arc, char **argv) usage(); } + if (td_body == sender_body && g.src_mac == NULL) { + static char mybuf[20] = "ff:ff:ff:ff:ff:ff"; + /* retrieve source mac address. */ + if (source_hwaddr(ifname, mybuf) == -1) { + D("Unable to retrieve source mac"); + // continue, fail later + } + g.src_mac = mybuf; + } + + if (g.use_pcap) { + D("using pcap on %s", ifname); + g.p = pcap_open_live(ifname, 0, 1, 100, pcap_errbuf); + if (g.p == NULL) { + D("cannot open pcap on %s", ifname); + usage(); + } + mmap_addr = NULL; + fd = -1; + } else { bzero(&nmr, sizeof(nmr)); nmr.nr_version = NETMAP_API; /* @@ -811,16 +890,6 @@ main(int arc, char **argv) // continue, fail later } - if (td_body == sender_body && g.src_mac == NULL) { - static char mybuf[20] = "ff:ff:ff:ff:ff:ff"; - /* retrieve source mac address. */ - if (source_hwaddr(ifname, mybuf) == -1) { - D("Unable to retrieve source mac"); - // continue, fail later - } - g.src_mac = mybuf; - } - /* * Map the netmap shared memory: instead of issuing mmap() * inside the body of the threads, we prefer to keep this @@ -869,8 +938,15 @@ main(int arc, char **argv) D("aborting"); usage(); } + } - + if (g.options) { + D("special options:%s%s%s%s\n", + g.options & OPT_PREFETCH ? " prefetch" : "", + g.options & OPT_ACCESS ? " access" : "", + g.options & OPT_MEMCPY ? " memcpy" : "", + g.options & OPT_COPY ? " copy" : ""); + } /* Wait for PHY reset. */ D("Wait %d secs for phy reset", wait_link); sleep(wait_link); @@ -881,7 +957,12 @@ main(int arc, char **argv) signal(SIGINT, sigint_h); if (g.use_pcap) { - // XXX g.p = pcap_open_live(..); + g.p = pcap_open_live(ifname, 0, 1, 100, NULL); + if (g.p == NULL) { + D("cannot open pcap on %s", ifname); + usage(); + } else + D("using pcap %p on %s", g.p, ifname); } targs = calloc(g.nthreads, sizeof(*targs)); @@ -1018,9 +1099,11 @@ main(int arc, char **argv) rx_output(count, delta_t); } + if (g.use_pcap == 0) { ioctl(fd, NIOCUNREGIF, &nmr); munmap(mmap_addr, nmr.nr_memsize); close(fd); + } return (0); } From owner-svn-src-head@FreeBSD.ORG Thu May 3 15:51:34 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C00AA1065686; Thu, 3 May 2012 15:51:34 +0000 (UTC) (envelope-from brueffer@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AAD618FC16; Thu, 3 May 2012 15:51:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43FpY17049899; Thu, 3 May 2012 15:51:34 GMT (envelope-from brueffer@svn.freebsd.org) Received: (from brueffer@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43FpYBr049897; Thu, 3 May 2012 15:51:34 GMT (envelope-from brueffer@svn.freebsd.org) Message-Id: <201205031551.q43FpYBr049897@svn.freebsd.org> From: Christian Brueffer Date: Thu, 3 May 2012 15:51:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234957 - head/sys/security/mac_mls X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:51:34 -0000 Author: brueffer Date: Thu May 3 15:51:34 2012 New Revision: 234957 URL: http://svn.freebsd.org/changeset/base/234957 Log: Check vplabel for NULL before dereferencing it. Fixes a panic when running atop with MAC_MLS enabled. Submitted by: Richard Kojedzinszky Reviewed by: rwatson MFC after: 1 week Modified: head/sys/security/mac_mls/mac_mls.c Modified: head/sys/security/mac_mls/mac_mls.c ============================================================================== --- head/sys/security/mac_mls/mac_mls.c Thu May 3 15:37:05 2012 (r234956) +++ head/sys/security/mac_mls/mac_mls.c Thu May 3 15:51:34 2012 (r234957) @@ -2028,6 +2028,9 @@ mls_system_check_acct(struct ucred *cred if (!mls_enabled) return (0); + if (vplabel == NULL) + return (0); + subj = SLOT(cred->cr_label); obj = SLOT(vplabel); From owner-svn-src-head@FreeBSD.ORG Thu May 3 15:54:07 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F529106566C; Thu, 3 May 2012 15:54:07 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A0EF8FC1C; Thu, 3 May 2012 15:54:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43Fs76H050023; Thu, 3 May 2012 15:54:07 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Fs78Q050021; Thu, 3 May 2012 15:54:07 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201205031554.q43Fs78Q050021@svn.freebsd.org> From: David Chisnall Date: Thu, 3 May 2012 15:54:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234958 - head/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 15:54:07 -0000 Author: theraven Date: Thu May 3 15:54:06 2012 New Revision: 234958 URL: http://svn.freebsd.org/changeset/base/234958 Log: Fix after clang decided to rename all of its builtins to include a c11 prefix to disambiguate them from the one provided by GCC. Note: Clang 3.1 also supports the GCC builtins for libstdc++ 4.7 compatibility, but I don't recommend using them because they are very poorly designed. MFC after: 2 weeks Modified: head/include/stdatomic.h Modified: head/include/stdatomic.h ============================================================================== --- head/include/stdatomic.h Thu May 3 15:51:34 2012 (r234957) +++ head/include/stdatomic.h Thu May 3 15:54:06 2012 (r234958) @@ -51,7 +51,7 @@ #if defined(__CLANG_ATOMICS) #define ATOMIC_VAR_INIT(value) (value) -#define atomic_init(obj, value) __atomic_init(obj, value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) #else #define ATOMIC_VAR_INIT(value) { .__val = (value) } #define atomic_init(obj, value) do { \ @@ -104,7 +104,10 @@ enum memory_order { * 7.17.4 Fences. */ -#if defined(__CLANG_ATOMICS) || defined(__GNUC_ATOMICS) +#ifdef __CLANG_ATOMICS +#define atomic_thread_fence(order) __c11_atomic_thread_fence(order) +#define atomic_signal_fence(order) __c11_atomic_signal_fence(order) +#elif defined(__GNUC_ATOMICS) #define atomic_thread_fence(order) __atomic_thread_fence(order) #define atomic_signal_fence(order) __atomic_signal_fence(order) #else @@ -118,7 +121,7 @@ enum memory_order { #if defined(__CLANG_ATOMICS) #define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof(obj)) + __c11_atomic_is_lock_free(sizeof(obj)) #elif defined(__GNUC_ATOMICS) #define atomic_is_lock_free(obj) \ __atomic_is_lock_free(sizeof((obj)->__val)) @@ -182,28 +185,28 @@ typedef _Atomic(__uintmax_t) atomic_uin #if defined(__CLANG_ATOMICS) #define atomic_compare_exchange_strong_explicit(object, expected, \ desired, success, failure) \ - __atomic_compare_exchange_strong(object, expected, desired, \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ success, failure) #define atomic_compare_exchange_weak_explicit(object, expected, \ desired, success, failure) \ - __atomic_compare_exchange_weak(object, expected, desired, \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ success, failure) #define atomic_exchange_explicit(object, desired, order) \ - __atomic_exchange(object, desired, order) + __c11_atomic_exchange(object, desired, order) #define atomic_fetch_add_explicit(object, operand, order) \ - __atomic_fetch_add(object, operand, order) + __c11_atomic_fetch_add(object, operand, order) #define atomic_fetch_and_explicit(object, operand, order) \ - __atomic_fetch_and(object, operand, order) + __c11_atomic_fetch_and(object, operand, order) #define atomic_fetch_or_explicit(object, operand, order) \ - __atomic_fetch_or(object, operand, order) + __c11_atomic_fetch_or(object, operand, order) #define atomic_fetch_sub_explicit(object, operand, order) \ - __atomic_fetch_sub(object, operand, order) + __c11_atomic_fetch_sub(object, operand, order) #define atomic_fetch_xor_explicit(object, operand, order) \ - __atomic_fetch_xor(object, operand, order) + __c11_atomic_fetch_xor(object, operand, order) #define atomic_load_explicit(object, order) \ - __atomic_load(object, order) + __c11_atomic_load(object, order) #define atomic_store_explicit(object, desired, order) \ - __atomic_store(object, desired, order) + __c11_atomic_store(object, desired, order) #elif defined(__GNUC_ATOMICS) #define atomic_compare_exchange_strong_explicit(object, expected, \ desired, success, failure) \ From owner-svn-src-head@FreeBSD.ORG Thu May 3 16:06:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 036A01065670; Thu, 3 May 2012 16:06:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D83748FC1F; Thu, 3 May 2012 16:06:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43G6M5E050628; Thu, 3 May 2012 16:06:22 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43G6McP050625; Thu, 3 May 2012 16:06:22 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201205031606.q43G6McP050625@svn.freebsd.org> From: Hans Petter Selasky Date: Thu, 3 May 2012 16:06:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234961 - in head/sys/dev/usb: . controller X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:06:23 -0000 Author: hselasky Date: Thu May 3 16:06:22 2012 New Revision: 234961 URL: http://svn.freebsd.org/changeset/base/234961 Log: Make sure the EHCI bandwidth allocation algorithm for FULL speed SPLIT transactions works fully. MFC after: 1 week Modified: head/sys/dev/usb/controller/ehci.c head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/controller/ehci.c ============================================================================== --- head/sys/dev/usb/controller/ehci.c Thu May 3 16:05:34 2012 (r234960) +++ head/sys/dev/usb/controller/ehci.c Thu May 3 16:06:22 2012 (r234961) @@ -2638,11 +2638,29 @@ ehci_device_isoc_fs_enter(struct usb_xfe /* update isoc_next */ xfer->endpoint->isoc_next = (pp_last - &sc->sc_isoc_fs_p_last[0]) & (EHCI_VIRTUAL_FRAMELIST_COUNT - 1); + + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; } static void ehci_device_isoc_fs_start(struct usb_xfer *xfer) { + /* + * We don't allow cancelling of the SPLIT transaction USB FULL + * speed transfer, because it disturbs the bandwidth + * computation algorithm. + */ + xfer->flags_int.can_cancel_immed = 0; + + /* set a default timeout */ + if (xfer->timeout == 0) + xfer->timeout = 500; /* ms */ + /* put transfer on interrupt queue */ ehci_transfer_intr_enqueue(xfer); } Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Thu May 3 16:05:34 2012 (r234960) +++ head/sys/dev/usb/usb_transfer.c Thu May 3 16:06:22 2012 (r234961) @@ -1681,11 +1681,12 @@ usbd_pipe_enter(struct usb_xfer *xfer) DPRINTF("enter\n"); + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* enter the transfer */ (ep->methods->enter) (xfer); - xfer->flags_int.can_cancel_immed = 1; - /* check for transfer error */ if (xfer->error) { /* some error has happened */ @@ -2418,13 +2419,15 @@ usbd_transfer_start_cb(void *arg) #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); @@ -2599,13 +2602,14 @@ usbd_pipe_start(struct usb_xfer_queue *p #if USB_HAVE_PF usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT); #endif + /* the transfer can now be cancelled */ + xfer->flags_int.can_cancel_immed = 1; + /* start USB transfer, if no error */ if (xfer->error == 0) (ep->methods->start) (xfer); - xfer->flags_int.can_cancel_immed = 1; - - /* check for error */ + /* check for transfer error */ if (xfer->error) { /* some error has happened */ usbd_transfer_done(xfer, 0); From owner-svn-src-head@FreeBSD.ORG Thu May 3 16:09:44 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B432A106566C; Thu, 3 May 2012 16:09:44 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9F5438FC12; Thu, 3 May 2012 16:09:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43G9i4O050766; Thu, 3 May 2012 16:09:44 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43G9inj050764; Thu, 3 May 2012 16:09:44 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031609.q43G9inj050764@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 16:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234962 - head/tools/tools/netmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:09:44 -0000 Author: luigi Date: Thu May 3 16:09:44 2012 New Revision: 234962 URL: http://svn.freebsd.org/changeset/base/234962 Log: add some performance data Modified: head/tools/tools/netmap/README Modified: head/tools/tools/netmap/README ============================================================================== --- head/tools/tools/netmap/README Thu May 3 16:06:22 2012 (r234961) +++ head/tools/tools/netmap/README Thu May 3 16:09:44 2012 (r234962) @@ -9,3 +9,14 @@ This directory contains examples that us testpcap a jumper wire using libnetmap (or libpcap) click* various click examples + +------------------------------------------------------------ +Some performance data as of may 2012 for applications using libpcap. +Throughput is generally in Mpps computed with the 64-byte frames, +using 1 core on a 2.9GHz CPU and 10Gbit/s interface + +Libpcap version -- Application --------------------- +BSD netmap +--------------------------------------------------- + 0.77 3.82 ports/trafshow (version 5) + 0.94 7.7 net-mgmt/ipcad (ip accounting daemon) From owner-svn-src-head@FreeBSD.ORG Thu May 3 16:14:41 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BBE0E1065674; Thu, 3 May 2012 16:14:41 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 750748FC14; Thu, 3 May 2012 16:14:41 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 997ED7300A; Thu, 3 May 2012 18:34:33 +0200 (CEST) Date: Thu, 3 May 2012 18:34:33 +0200 From: Luigi Rizzo To: "Alexander V. Chernikov" Message-ID: <20120503163433.GA4727@onelab2.iet.unipi.it> References: <201204301022.q3UAMNcq060049@svn.freebsd.org> <20120430114836.GA62284@onelab2.iet.unipi.it> <20120430113610.GC18777@FreeBSD.org> <4F9E82DA.4030406@FreeBSD.org> <20120430133904.GA65792@onelab2.iet.unipi.it> <4FA24920.4080809@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FA24920.4080809@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-head@FreeBSD.org, ae@FreeBSD.org, svn-src-all@FreeBSD.org, Gleb Smirnoff , src-committers@FreeBSD.org Subject: Re: svn commit: r234834 - in head/sys: contrib/pf/net net netinet netinet/ipfw ofed/drivers/infiniband/ulp/ipoib X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 16:14:41 -0000 On Thu, May 03, 2012 at 01:00:16PM +0400, Alexander V. Chernikov wrote: ... > Reverted in r234946 thank you very much for the quick resolution of the issue. I really appreciate it. cheers luigi From owner-svn-src-head@FreeBSD.ORG Thu May 3 17:08:41 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4E46410656B5; Thu, 3 May 2012 17:08:41 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 398218FC15; Thu, 3 May 2012 17:08:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43H8fQO053626; Thu, 3 May 2012 17:08:41 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43H8fax053623; Thu, 3 May 2012 17:08:41 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205031708.q43H8fax053623@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 17:08:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234975 - head/tools/tools/netmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 17:08:41 -0000 Author: luigi Date: Thu May 3 17:08:40 2012 New Revision: 234975 URL: http://svn.freebsd.org/changeset/base/234975 Log: add support for pcap receive statistics (used by net-mgmt/darkstat) Modified: head/tools/tools/netmap/README head/tools/tools/netmap/pcap.c Modified: head/tools/tools/netmap/README ============================================================================== --- head/tools/tools/netmap/README Thu May 3 16:54:32 2012 (r234974) +++ head/tools/tools/netmap/README Thu May 3 17:08:40 2012 (r234975) @@ -20,3 +20,4 @@ BSD netmap --------------------------------------------------- 0.77 3.82 ports/trafshow (version 5) 0.94 7.7 net-mgmt/ipcad (ip accounting daemon) + 0.9 5.0 net-mgmt/darkstat (ip accounting + graphing) Modified: head/tools/tools/netmap/pcap.c ============================================================================== --- head/tools/tools/netmap/pcap.c Thu May 3 16:54:32 2012 (r234974) +++ head/tools/tools/netmap/pcap.c Thu May 3 17:08:40 2012 (r234975) @@ -154,6 +154,8 @@ int pcap_setdirection(pcap_t *p, pcap_di char *pcap_lookupdev(char *errbuf); int pcap_inject(pcap_t *p, const void *buf, size_t size); int pcap_fileno(pcap_t *p); +const char *pcap_lib_version(void); + struct eproto { const char *s; @@ -318,6 +320,11 @@ struct eproto eproto_db[] = { }; +const char *pcap_lib_version(void) +{ + return pcap_version; +} + int pcap_findalldevs(pcap_if_t **alldevsp, __unused char *errbuf) { @@ -532,10 +539,8 @@ pcap_stats(pcap_t *p, struct pcap_stat * struct my_ring *me = p; ND(""); - me->st.ps_recv += 10; *ps = me->st; - sprintf(me->msg, "stats not supported"); - return -1; + return 0; /* accumulate from pcap_dispatch() */ }; char * @@ -670,6 +675,7 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_h got++; } } + me->st.ps_recv += got; return got; } From owner-svn-src-head@FreeBSD.ORG Thu May 3 17:44:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 76AC71065697; Thu, 3 May 2012 17:44:08 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F5158FC08; Thu, 3 May 2012 17:44:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43Hi8oA054902; Thu, 3 May 2012 17:44:08 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Hi8fj054896; Thu, 3 May 2012 17:44:08 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201205031744.q43Hi8fj054896@svn.freebsd.org> From: David Chisnall Date: Thu, 3 May 2012 17:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234976 - in head/contrib/libc++: include src X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 17:44:08 -0000 Author: theraven Date: Thu May 3 17:44:07 2012 New Revision: 234976 URL: http://svn.freebsd.org/changeset/base/234976 Log: Import new version of libc++. Among other improvements, this comes with an header that works with clang 3.1 (and, importantly, the pre-3.1 snapshot currently in head) Modified: head/contrib/libc++/include/__config head/contrib/libc++/include/__tuple head/contrib/libc++/include/algorithm head/contrib/libc++/include/atomic head/contrib/libc++/include/cmath head/contrib/libc++/include/limits head/contrib/libc++/include/memory head/contrib/libc++/include/random head/contrib/libc++/include/system_error head/contrib/libc++/include/tuple head/contrib/libc++/include/type_traits head/contrib/libc++/include/utility head/contrib/libc++/src/iostream.cpp head/contrib/libc++/src/stdexcept.cpp head/contrib/libc++/src/utility.cpp Directory Properties: head/contrib/libc++/ (props changed) Modified: head/contrib/libc++/include/__config ============================================================================== --- head/contrib/libc++/include/__config Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/__config Thu May 3 17:44:07 2012 (r234976) @@ -384,7 +384,9 @@ template struct __static_asse #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR -#define constexpr const +#define _LIBCPP_CONSTEXPR +#else +#define _LIBCPP_CONSTEXPR constexpr #endif #ifndef __has_feature Modified: head/contrib/libc++/include/__tuple ============================================================================== --- head/contrib/libc++/include/__tuple Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/__tuple Thu May 3 17:44:07 2012 (r234976) @@ -216,7 +216,7 @@ struct __tuple_convertible_imp : public template struct __tuple_convertible_imp, __tuple_types<_Up0, _Up...> > : public integral_constant::value && + is_convertible<_Tp0, _Up0>::value && __tuple_convertible_imp, __tuple_types<_Up...> >::value> {}; template <> @@ -235,6 +235,33 @@ struct __tuple_convertible<_Tp, _Up, tru typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> {}; +// __tuple_constructible + +template +struct __tuple_constructible_imp : public false_type {}; + +template +struct __tuple_constructible_imp, __tuple_types<_Up0, _Up...> > + : public integral_constant::value && + __tuple_constructible_imp, __tuple_types<_Up...> >::value> {}; + +template <> +struct __tuple_constructible_imp, __tuple_types<> > + : public true_type {}; + +template ::type>::value, + bool = __tuple_like<_Up>::value> +struct __tuple_constructible + : public false_type {}; + +template +struct __tuple_constructible<_Tp, _Up, true, true> + : public __tuple_constructible_imp::type>::value == + tuple_size<_Up>::value, + typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> +{}; + // __tuple_assignable template Modified: head/contrib/libc++/include/algorithm ============================================================================== --- head/contrib/libc++/include/algorithm Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/algorithm Thu May 3 17:44:07 2012 (r234976) @@ -2508,11 +2508,16 @@ private: _Engine_result_type __mask0_; _Engine_result_type __mask1_; +#ifdef _LIBCPP_HAS_NO_CONSTEXPR static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min - + _Working_result_type(1); - static const size_t __m = __log2<_Working_result_type, _Rp>::value; - static const size_t _WDt = numeric_limits<_Working_result_type>::digits; - static const size_t _EDt = numeric_limits<_Engine_result_type>::digits; + + _Working_result_type(1); +#else + static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() + + _Working_result_type(1); +#endif + static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; + static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; + static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; public: // constructors and seeding functions @@ -2712,8 +2717,8 @@ public: result_type operator()(); - static constexpr result_type min() {return _Min;} - static constexpr result_type max() {return _Max;} + static _LIBCPP_CONSTEXPR result_type min() {return _Min;} + static _LIBCPP_CONSTEXPR result_type max() {return _Max;} friend __rs_default __rs_get(); }; Modified: head/contrib/libc++/include/atomic ============================================================================== --- head/contrib/libc++/include/atomic Thu May 3 17:08:40 2012 (r234975) +++ head/contrib/libc++/include/atomic Thu May 3 17:44:07 2012 (r234976) @@ -29,7 +29,7 @@ typedef enum memory_order memory_order_seq_cst // store-release load-acquire } memory_order; -template T kill_dependency(T y); +template T kill_dependency(T y) noexcept; // lock-free property @@ -46,40 +46,40 @@ template T kill_dependency(T y typedef struct atomic_flag { - bool test_and_set(memory_order m = memory_order_seq_cst) volatile; - bool test_and_set(memory_order m = memory_order_seq_cst); - void clear(memory_order m = memory_order_seq_cst) volatile; - void clear(memory_order m = memory_order_seq_cst); - atomic_flag() = default; + bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept; + bool test_and_set(memory_order m = memory_order_seq_cst) noexcept; + void clear(memory_order m = memory_order_seq_cst) volatile noexcept; + void clear(memory_order m = memory_order_seq_cst) noexcept; + atomic_flag() noexcept = default; atomic_flag(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) volatile = delete; } atomic_flag; bool - atomic_flag_test_and_set(volatile atomic_flag* obj); + atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept; bool - atomic_flag_test_and_set(atomic_flag* obj); + atomic_flag_test_and_set(atomic_flag* obj) noexcept; bool atomic_flag_test_and_set_explicit(volatile atomic_flag* obj, - memory_order m); + memory_order m) noexcept; bool - atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m); + atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept; void - atomic_flag_clear(volatile atomic_flag* obj); + atomic_flag_clear(volatile atomic_flag* obj) noexcept; void - atomic_flag_clear(atomic_flag* obj); + atomic_flag_clear(atomic_flag* obj) noexcept; void - atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m); + atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; void - atomic_flag_clear_explicit(atomic_flag* obj, memory_order m); + atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; #define ATOMIC_FLAG_INIT see below #define ATOMIC_VAR_INIT(value) see below @@ -87,388 +87,388 @@ void template struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(T desr, memory_order m = memory_order_seq_cst) volatile; - void store(T desr, memory_order m = memory_order_seq_cst); - T load(memory_order m = memory_order_seq_cst) const volatile; - T load(memory_order m = memory_order_seq_cst) const; - operator T() const volatile; - operator T() const; - T exchange(T desr, memory_order m = memory_order_seq_cst) volatile; - T exchange(T desr, memory_order m = memory_order_seq_cst); + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(T desr, memory_order m = memory_order_seq_cst) noexcept; + T load(memory_order m = memory_order_seq_cst) const volatile noexcept; + T load(memory_order m = memory_order_seq_cst) const noexcept; + operator T() const volatile noexcept; + operator T() const noexcept; + T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept; + T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order s, memory_order f) volatile; - bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f); + memory_order s, memory_order f) volatile noexcept; + bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(T& expc, T desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(T& expc, T desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(T desr); + atomic() noexcept = default; + constexpr atomic(T desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - T operator=(T) volatile; - T operator=(T); + T operator=(T) volatile noexcept; + T operator=(T) noexcept; }; template <> struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(integral desr, memory_order m = memory_order_seq_cst) volatile; - void store(integral desr, memory_order m = memory_order_seq_cst); - integral load(memory_order m = memory_order_seq_cst) const volatile; - integral load(memory_order m = memory_order_seq_cst) const; - operator integral() const volatile; - operator integral() const; + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(integral desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(integral desr, memory_order m = memory_order_seq_cst) noexcept; + integral load(memory_order m = memory_order_seq_cst) const volatile noexcept; + integral load(memory_order m = memory_order_seq_cst) const noexcept; + operator integral() const volatile noexcept; + operator integral() const noexcept; integral exchange(integral desr, - memory_order m = memory_order_seq_cst) volatile; - integral exchange(integral desr, memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) volatile noexcept; + integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(integral& expc, integral desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(integral& expc, integral desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; integral - fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_add(integral op, memory_order m = memory_order_seq_cst); + fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_sub(integral op, memory_order m = memory_order_seq_cst); + fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_and(integral op, memory_order m = memory_order_seq_cst); + fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_or(integral op, memory_order m = memory_order_seq_cst); + fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept; integral - fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile; - integral fetch_xor(integral op, memory_order m = memory_order_seq_cst); + fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept; + integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(integral desr); + atomic() noexcept = default; + constexpr atomic(integral desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - integral operator=(integral desr) volatile; - integral operator=(integral desr); + integral operator=(integral desr) volatile noexcept; + integral operator=(integral desr) noexcept; - integral operator++(int) volatile; - integral operator++(int); - integral operator--(int) volatile; - integral operator--(int); - integral operator++() volatile; - integral operator++(); - integral operator--() volatile; - integral operator--(); - integral operator+=(integral op) volatile; - integral operator+=(integral op); - integral operator-=(integral op) volatile; - integral operator-=(integral op); - integral operator&=(integral op) volatile; - integral operator&=(integral op); - integral operator|=(integral op) volatile; - integral operator|=(integral op); - integral operator^=(integral op) volatile; - integral operator^=(integral op); + integral operator++(int) volatile noexcept; + integral operator++(int) noexcept; + integral operator--(int) volatile noexcept; + integral operator--(int) noexcept; + integral operator++() volatile noexcept; + integral operator++() noexcept; + integral operator--() volatile noexcept; + integral operator--() noexcept; + integral operator+=(integral op) volatile noexcept; + integral operator+=(integral op) noexcept; + integral operator-=(integral op) volatile noexcept; + integral operator-=(integral op) noexcept; + integral operator&=(integral op) volatile noexcept; + integral operator&=(integral op) noexcept; + integral operator|=(integral op) volatile noexcept; + integral operator|=(integral op) noexcept; + integral operator^=(integral op) volatile noexcept; + integral operator^=(integral op) noexcept; }; template struct atomic { - bool is_lock_free() const volatile; - bool is_lock_free() const; - void store(T* desr, memory_order m = memory_order_seq_cst) volatile; - void store(T* desr, memory_order m = memory_order_seq_cst); - T* load(memory_order m = memory_order_seq_cst) const volatile; - T* load(memory_order m = memory_order_seq_cst) const; - operator T*() const volatile; - operator T*() const; - T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile; - T* exchange(T* desr, memory_order m = memory_order_seq_cst); + bool is_lock_free() const volatile noexcept; + bool is_lock_free() const noexcept; + void store(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; + void store(T* desr, memory_order m = memory_order_seq_cst) noexcept; + T* load(memory_order m = memory_order_seq_cst) const volatile noexcept; + T* load(memory_order m = memory_order_seq_cst) const noexcept; + operator T*() const volatile noexcept; + operator T*() const noexcept; + T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept; + T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order s, memory_order f) volatile; + memory_order s, memory_order f) volatile noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_weak(T*& expc, T* desr, - memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order m = memory_order_seq_cst) volatile; + memory_order m = memory_order_seq_cst) volatile noexcept; bool compare_exchange_strong(T*& expc, T* desr, - memory_order m = memory_order_seq_cst); - T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile; - T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst); - T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile; - T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst); + memory_order m = memory_order_seq_cst) noexcept; + T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; + T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; + T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept; + T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept; - atomic() = default; - constexpr atomic(T* desr); + atomic() noexcept = default; + constexpr atomic(T* desr) noexcept; atomic(const atomic&) = delete; atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - T* operator=(T*) volatile; - T* operator=(T*); - T* operator++(int) volatile; - T* operator++(int); - T* operator--(int) volatile; - T* operator--(int); - T* operator++() volatile; - T* operator++(); - T* operator--() volatile; - T* operator--(); - T* operator+=(ptrdiff_t op) volatile; - T* operator+=(ptrdiff_t op); - T* operator-=(ptrdiff_t op) volatile; - T* operator-=(ptrdiff_t op); + T* operator=(T*) volatile noexcept; + T* operator=(T*) noexcept; + T* operator++(int) volatile noexcept; + T* operator++(int) noexcept; + T* operator--(int) volatile noexcept; + T* operator--(int) noexcept; + T* operator++() volatile noexcept; + T* operator++() noexcept; + T* operator--() volatile noexcept; + T* operator--() noexcept; + T* operator+=(ptrdiff_t op) volatile noexcept; + T* operator+=(ptrdiff_t op) noexcept; + T* operator-=(ptrdiff_t op) volatile noexcept; + T* operator-=(ptrdiff_t op) noexcept; }; template bool - atomic_is_lock_free(const volatile atomic* obj); + atomic_is_lock_free(const volatile atomic* obj) noexcept; template bool - atomic_is_lock_free(const atomic* obj); + atomic_is_lock_free(const atomic* obj) noexcept; template void - atomic_init(volatile atomic* obj, T desr); + atomic_init(volatile atomic* obj, T desr) noexcept; template void - atomic_init(atomic* obj, T desr); + atomic_init(atomic* obj, T desr) noexcept; template void - atomic_store(volatile atomic* obj, T desr); + atomic_store(volatile atomic* obj, T desr) noexcept; template void - atomic_store(atomic* obj, T desr); + atomic_store(atomic* obj, T desr) noexcept; template void - atomic_store_explicit(volatile atomic* obj, T desr, memory_order m); + atomic_store_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template void - atomic_store_explicit(atomic* obj, T desr, memory_order m); + atomic_store_explicit(atomic* obj, T desr, memory_order m) noexcept; template T - atomic_load(const volatile atomic* obj); + atomic_load(const volatile atomic* obj) noexcept; template T - atomic_load(const atomic* obj); + atomic_load(const atomic* obj) noexcept; template T - atomic_load_explicit(const volatile atomic* obj, memory_order m); + atomic_load_explicit(const volatile atomic* obj, memory_order m) noexcept; template T - atomic_load_explicit(const atomic* obj, memory_order m); + atomic_load_explicit(const atomic* obj, memory_order m) noexcept; template T - atomic_exchange(volatile atomic* obj, T desr); + atomic_exchange(volatile atomic* obj, T desr) noexcept; template T - atomic_exchange(atomic* obj, T desr); + atomic_exchange(atomic* obj, T desr) noexcept; template T - atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m); + atomic_exchange_explicit(volatile atomic* obj, T desr, memory_order m) noexcept; template T - atomic_exchange_explicit(atomic* obj, T desr, memory_order m); + atomic_exchange_explicit(atomic* obj, T desr, memory_order m) noexcept; template bool - atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr); + atomic_compare_exchange_weak(volatile atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_weak(atomic* obj, T* expc, T desr); + atomic_compare_exchange_weak(atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr); + atomic_compare_exchange_strong(volatile atomic* obj, T* expc, T desr) noexcept; template bool - atomic_compare_exchange_strong(atomic* obj, T* expc, T desr); + atomic_compare_exchange_strong(atomic* obj, T* expc, T desr) noexcept; template bool atomic_compare_exchange_weak_explicit(volatile atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_weak_explicit(atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(volatile atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template bool atomic_compare_exchange_strong_explicit(atomic* obj, T* expc, T desr, - memory_order s, memory_order f); + memory_order s, memory_order f) noexcept; template Integral - atomic_fetch_add(volatile atomic* obj, Integral op); + atomic_fetch_add(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_add(atomic* obj, Integral op); + atomic_fetch_add(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_add_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_add_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_sub(volatile atomic* obj, Integral op); + atomic_fetch_sub(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_sub(atomic* obj, Integral op); + atomic_fetch_sub(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_sub_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_sub_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_and(volatile atomic* obj, Integral op); + atomic_fetch_and(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_and(atomic* obj, Integral op); + atomic_fetch_and(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_and_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_and_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_or(volatile atomic* obj, Integral op); + atomic_fetch_or(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_or(atomic* obj, Integral op); + atomic_fetch_or(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_or_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_or_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral - atomic_fetch_xor(volatile atomic* obj, Integral op); + atomic_fetch_xor(volatile atomic* obj, Integral op) noexcept; template Integral - atomic_fetch_xor(atomic* obj, Integral op); + atomic_fetch_xor(atomic* obj, Integral op) noexcept; template Integral atomic_fetch_xor_explicit(volatile atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template Integral atomic_fetch_xor_explicit(atomic* obj, Integral op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_add(volatile atomic* obj, ptrdiff_t op); + atomic_fetch_add(volatile atomic* obj, ptrdiff_t op) noexcept; template T* - atomic_fetch_add(atomic* obj, ptrdiff_t op); + atomic_fetch_add(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_add_explicit(volatile atomic* obj, ptrdiff_t op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m); + atomic_fetch_add_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; template T* - atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op); + atomic_fetch_sub(volatile atomic* obj, ptrdiff_t op) noexcept; template T* - atomic_fetch_sub(atomic* obj, ptrdiff_t op); + atomic_fetch_sub(atomic* obj, ptrdiff_t op) noexcept; template T* atomic_fetch_sub_explicit(volatile atomic* obj, ptrdiff_t op, - memory_order m); + memory_order m) noexcept; template T* - atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m); + atomic_fetch_sub_explicit(atomic* obj, ptrdiff_t op, memory_order m) noexcept; // Atomics for standard typedef types @@ -514,8 +514,8 @@ typedef atomic atomic_uintmax // fences -void atomic_thread_fence(memory_order m); -void atomic_signal_fence(memory_order m); +void atomic_thread_fence(memory_order m) noexcept; +void atomic_signal_fence(memory_order m) noexcept; } // std @@ -545,7 +545,7 @@ typedef enum memory_order template inline _LIBCPP_INLINE_VISIBILITY _Tp -kill_dependency(_Tp __y) +kill_dependency(_Tp __y) _NOEXCEPT { return __y; } @@ -558,70 +558,70 @@ struct __atomic_base // false _Atomic(_Tp) __a_; _LIBCPP_INLINE_VISIBILITY - bool is_lock_free() const volatile - {return __atomic_is_lock_free(_Tp());} + bool is_lock_free() const volatile _NOEXCEPT + {return __c11_atomic_is_lock_free(sizeof(_Tp));} _LIBCPP_INLINE_VISIBILITY - bool is_lock_free() const - {return __atomic_is_lock_free(_Tp());} + bool is_lock_free() const _NOEXCEPT + {return __c11_atomic_is_lock_free(sizeof(_Tp));} _LIBCPP_INLINE_VISIBILITY - void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile - {__atomic_store(&__a_, __d, __m);} + void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {__c11_atomic_store(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - void store(_Tp __d, memory_order __m = memory_order_seq_cst) - {__atomic_store(&__a_, __d, __m);} + void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {__c11_atomic_store(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp load(memory_order __m = memory_order_seq_cst) const volatile - {return __atomic_load(&__a_, __m);} + _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT + {return __c11_atomic_load(&__a_, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp load(memory_order __m = memory_order_seq_cst) const - {return __atomic_load(&__a_, __m);} + _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT + {return __c11_atomic_load(&__a_, __m);} _LIBCPP_INLINE_VISIBILITY - operator _Tp() const volatile {return load();} + operator _Tp() const volatile _NOEXCEPT {return load();} _LIBCPP_INLINE_VISIBILITY - operator _Tp() const {return load();} + operator _Tp() const _NOEXCEPT {return load();} _LIBCPP_INLINE_VISIBILITY - _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_exchange(&__a_, __d, __m);} + _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_exchange(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) - {return __atomic_exchange(&__a_, __d, __m);} + _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_exchange(&__a_, __d, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) volatile - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) volatile - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __s, memory_order __f) - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} + memory_order __s, memory_order __f) _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) volatile - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_weak(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) - {return __atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) volatile - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY bool compare_exchange_strong(_Tp& __e, _Tp __d, - memory_order __m = memory_order_seq_cst) - {return __atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} + memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} _LIBCPP_INLINE_VISIBILITY - __atomic_base() {} // = default; + __atomic_base() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) { __atomic_store(&__a_, __d, memory_order_seq_cst); } + _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __atomic_base(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete; @@ -642,77 +642,77 @@ struct __atomic_base<_Tp, true> { typedef __atomic_base<_Tp, false> __base; _LIBCPP_INLINE_VISIBILITY - __atomic_base() {} // = default; + __atomic_base() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ __atomic_base(_Tp __d) : __base(__d) {} + _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_add(&this->__a_, __op, __m);} + _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_add(&this->__a_, __op, __m);} + _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_sub(&this->__a_, __op, __m);} + _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_sub(&this->__a_, __op, __m);} + _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_and(&this->__a_, __op, __m);} + _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_and(&this->__a_, __op, __m);} + _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_and(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_or(&this->__a_, __op, __m);} + _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_or(&this->__a_, __op, __m);} + _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_or(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile - {return __atomic_fetch_xor(&this->__a_, __op, __m);} + _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT + {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) - {return __atomic_fetch_xor(&this->__a_, __op, __m);} + _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT + {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp operator++(int) volatile {return fetch_add(_Tp(1));} + _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator++(int) {return fetch_add(_Tp(1));} + _Tp operator++(int) _NOEXCEPT {return fetch_add(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator--(int) volatile {return fetch_sub(_Tp(1));} + _Tp operator--(int) volatile _NOEXCEPT {return fetch_sub(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator--(int) {return fetch_sub(_Tp(1));} + _Tp operator--(int) _NOEXCEPT {return fetch_sub(_Tp(1));} _LIBCPP_INLINE_VISIBILITY - _Tp operator++() volatile {return fetch_add(_Tp(1)) + _Tp(1);} + _Tp operator++() volatile _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator++() {return fetch_add(_Tp(1)) + _Tp(1);} + _Tp operator++() _NOEXCEPT {return fetch_add(_Tp(1)) + _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator--() volatile {return fetch_sub(_Tp(1)) - _Tp(1);} + _Tp operator--() volatile _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator--() {return fetch_sub(_Tp(1)) - _Tp(1);} + _Tp operator--() _NOEXCEPT {return fetch_sub(_Tp(1)) - _Tp(1);} _LIBCPP_INLINE_VISIBILITY - _Tp operator+=(_Tp __op) volatile {return fetch_add(__op) + __op;} + _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator+=(_Tp __op) {return fetch_add(__op) + __op;} + _Tp operator+=(_Tp __op) _NOEXCEPT {return fetch_add(__op) + __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator-=(_Tp __op) volatile {return fetch_sub(__op) - __op;} + _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator-=(_Tp __op) {return fetch_sub(__op) - __op;} + _Tp operator-=(_Tp __op) _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator&=(_Tp __op) volatile {return fetch_and(__op) & __op;} + _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator&=(_Tp __op) {return fetch_and(__op) & __op;} + _Tp operator&=(_Tp __op) _NOEXCEPT {return fetch_and(__op) & __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator|=(_Tp __op) volatile {return fetch_or(__op) | __op;} + _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator|=(_Tp __op) {return fetch_or(__op) | __op;} + _Tp operator|=(_Tp __op) _NOEXCEPT {return fetch_or(__op) | __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator^=(_Tp __op) volatile {return fetch_xor(__op) ^ __op;} + _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;} _LIBCPP_INLINE_VISIBILITY - _Tp operator^=(_Tp __op) {return fetch_xor(__op) ^ __op;} + _Tp operator^=(_Tp __op) _NOEXCEPT {return fetch_xor(__op) ^ __op;} }; // atomic @@ -723,15 +723,15 @@ struct atomic { typedef __atomic_base<_Tp> __base; _LIBCPP_INLINE_VISIBILITY - atomic() {} // = default; + atomic() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ atomic(_Tp __d) : __base(__d) {} + _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp operator=(_Tp __d) volatile + _Tp operator=(_Tp __d) volatile _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY - _Tp operator=(_Tp __d) + _Tp operator=(_Tp __d) _NOEXCEPT {__base::store(__d); return __d;} }; @@ -743,56 +743,56 @@ struct atomic<_Tp*> { typedef __atomic_base<_Tp*> __base; _LIBCPP_INLINE_VISIBILITY - atomic() {} // = default; + atomic() _NOEXCEPT {} // = default; _LIBCPP_INLINE_VISIBILITY - /*constexpr*/ atomic(_Tp* __d) : __base(__d) {} + _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} _LIBCPP_INLINE_VISIBILITY - _Tp* operator=(_Tp* __d) volatile + _Tp* operator=(_Tp* __d) volatile _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY - _Tp* operator=(_Tp* __d) + _Tp* operator=(_Tp* __d) _NOEXCEPT {__base::store(__d); return __d;} _LIBCPP_INLINE_VISIBILITY _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) - volatile - {return __atomic_fetch_add(&this->__a_, __op, __m);} + volatile _NOEXCEPT + {return __c11_atomic_fetch_add(&this->__a_, __op, __m);} _LIBCPP_INLINE_VISIBILITY - _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Thu May 3 20:00:31 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 03D62106578C; Thu, 3 May 2012 20:00:31 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E2C878FC15; Thu, 3 May 2012 20:00:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43K0Ugl060622; Thu, 3 May 2012 20:00:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43K0Ure060620; Thu, 3 May 2012 20:00:30 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205032000.q43K0Ure060620@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 3 May 2012 20:00:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234981 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 20:00:31 -0000 Author: kib Date: Thu May 3 20:00:30 2012 New Revision: 234981 URL: http://svn.freebsd.org/changeset/base/234981 Log: Move the code to call the callout callback into the helper function softclock_call_cc(). While there, move some common code to callout_cc_del(). Requested by: avg, jhb Reviewed by: jhb MFC after: 1 week Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Thu May 3 19:56:50 2012 (r234980) +++ head/sys/kern/kern_timeout.c Thu May 3 20:00:30 2012 (r234981) @@ -437,6 +437,181 @@ callout_cc_add(struct callout *c, struct } } +static void +callout_cc_del(struct callout *c, struct callout_cpu *cc) +{ + + if (cc->cc_next == c) + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); + if (c->c_flags & CALLOUT_LOCAL_ALLOC) { + c->c_func = NULL; + SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); + } +} + +static struct callout * +softclock_call_cc(struct callout *c, struct callout_cpu *cc, int *mpcalls, + int *lockcalls, int *gcalls) +{ + void (*c_func)(void *); + void *c_arg; + struct lock_class *class; + struct lock_object *c_lock; + int c_flags, sharedlock; +#ifdef SMP + struct callout_cpu *new_cc; + void (*new_func)(void *); + void *new_arg; + int new_cpu, new_ticks; +#endif +#ifdef DIAGNOSTIC + struct bintime bt1, bt2; + struct timespec ts2; + static uint64_t maxdt = 36893488147419102LL; /* 2 msec */ + static timeout_t *lastfunc; +#endif + + cc->cc_next = TAILQ_NEXT(c, c_links.tqe); + class = (c->c_lock != NULL) ? LOCK_CLASS(c->c_lock) : NULL; + sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? 0 : 1; + c_lock = c->c_lock; + c_func = c->c_func; + c_arg = c->c_arg; + c_flags = c->c_flags; + if (c->c_flags & CALLOUT_LOCAL_ALLOC) + c->c_flags = CALLOUT_LOCAL_ALLOC; + else + c->c_flags &= ~CALLOUT_PENDING; + cc->cc_curr = c; + cc->cc_cancel = 0; + CC_UNLOCK(cc); + if (c_lock != NULL) { + class->lc_lock(c_lock, sharedlock); + /* + * The callout may have been cancelled + * while we switched locks. + */ + if (cc->cc_cancel) { + class->lc_unlock(c_lock); + goto skip; + } + /* The callout cannot be stopped now. */ + cc->cc_cancel = 1; + + if (c_lock == &Giant.lock_object) { + (*gcalls)++; + CTR3(KTR_CALLOUT, "callout %p func %p arg %p", + c, c_func, c_arg); + } else { + (*lockcalls)++; + CTR3(KTR_CALLOUT, "callout lock %p func %p arg %p", + c, c_func, c_arg); + } + } else { + (*mpcalls)++; + CTR3(KTR_CALLOUT, "callout mpsafe %p func %p arg %p", + c, c_func, c_arg); + } +#ifdef DIAGNOSTIC + binuptime(&bt1); +#endif + THREAD_NO_SLEEPING(); + SDT_PROBE(callout_execute, kernel, , callout_start, c, 0, 0, 0, 0); + c_func(c_arg); + SDT_PROBE(callout_execute, kernel, , callout_end, c, 0, 0, 0, 0); + THREAD_SLEEPING_OK(); +#ifdef DIAGNOSTIC + binuptime(&bt2); + bintime_sub(&bt2, &bt1); + if (bt2.frac > maxdt) { + if (lastfunc != c_func || bt2.frac > maxdt * 2) { + bintime2timespec(&bt2, &ts2); + printf( + "Expensive timeout(9) function: %p(%p) %jd.%09ld s\n", + c_func, c_arg, (intmax_t)ts2.tv_sec, ts2.tv_nsec); + } + maxdt = bt2.frac; + lastfunc = c_func; + } +#endif + CTR1(KTR_CALLOUT, "callout %p finished", c); + if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0) + class->lc_unlock(c_lock); +skip: + CC_LOCK(cc); + /* + * If the current callout is locally allocated (from + * timeout(9)) then put it on the freelist. + * + * Note: we need to check the cached copy of c_flags because + * if it was not local, then it's not safe to deref the + * callout pointer. + */ + if (c_flags & CALLOUT_LOCAL_ALLOC) { + KASSERT(c->c_flags == CALLOUT_LOCAL_ALLOC, + ("corrupted callout")); + c->c_func = NULL; + SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); + } + cc->cc_curr = NULL; + if (cc->cc_waiting) { + /* + * There is someone waiting for the + * callout to complete. + * If the callout was scheduled for + * migration just cancel it. + */ + if (cc_cme_migrating(cc)) + cc_cme_cleanup(cc); + cc->cc_waiting = 0; + CC_UNLOCK(cc); + wakeup(&cc->cc_waiting); + CC_LOCK(cc); + } else if (cc_cme_migrating(cc)) { +#ifdef SMP + /* + * If the callout was scheduled for + * migration just perform it now. + */ + new_cpu = cc->cc_migration_cpu; + new_ticks = cc->cc_migration_ticks; + new_func = cc->cc_migration_func; + new_arg = cc->cc_migration_arg; + cc_cme_cleanup(cc); + + /* + * Handle deferred callout stops + */ + if ((c->c_flags & CALLOUT_DFRMIGRATION) == 0) { + CTR3(KTR_CALLOUT, + "deferred cancelled %p func %p arg %p", + c, new_func, new_arg); + callout_cc_del(c, cc); + goto nextc; + } + + c->c_flags &= ~CALLOUT_DFRMIGRATION; + + /* + * It should be assert here that the + * callout is not destroyed but that + * is not easy. + */ + new_cc = callout_cpu_switch(c, cc, new_cpu); + callout_cc_add(c, new_cc, new_ticks, new_func, new_arg, + new_cpu); + CC_UNLOCK(new_cc); + CC_LOCK(cc); +#else + panic("migration should not happen"); +#endif + } +#ifdef SMP +nextc: +#endif + return (cc->cc_next); +} + /* * The callout mechanism is based on the work of Adam M. Costello and * George Varghese, published in a technical report entitled "Redesigning @@ -465,12 +640,6 @@ softclock(void *arg) int mpcalls; int lockcalls; int gcalls; -#ifdef DIAGNOSTIC - struct bintime bt1, bt2; - struct timespec ts2; - static uint64_t maxdt = 36893488147419102LL; /* 2 msec */ - static timeout_t *lastfunc; -#endif #ifndef MAX_SOFTCLOCK_STEPS #define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ @@ -492,7 +661,7 @@ softclock(void *arg) cc->cc_softticks++; bucket = &cc->cc_callwheel[curticks & callwheelmask]; c = TAILQ_FIRST(bucket); - while (c) { + while (c != NULL) { depth++; if (c->c_time != curticks) { c = TAILQ_NEXT(c, c_links.tqe); @@ -507,189 +676,10 @@ softclock(void *arg) steps = 0; } } else { - void (*c_func)(void *); - void *c_arg; - struct lock_class *class; - struct lock_object *c_lock; - int c_flags, sharedlock; - - cc->cc_next = TAILQ_NEXT(c, c_links.tqe); TAILQ_REMOVE(bucket, c, c_links.tqe); - class = (c->c_lock != NULL) ? - LOCK_CLASS(c->c_lock) : NULL; - sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? - 0 : 1; - c_lock = c->c_lock; - c_func = c->c_func; - c_arg = c->c_arg; - c_flags = c->c_flags; - if (c->c_flags & CALLOUT_LOCAL_ALLOC) { - c->c_flags = CALLOUT_LOCAL_ALLOC; - } else { - c->c_flags = - (c->c_flags & ~CALLOUT_PENDING); - } - cc->cc_curr = c; - cc->cc_cancel = 0; - CC_UNLOCK(cc); - if (c_lock != NULL) { - class->lc_lock(c_lock, sharedlock); - /* - * The callout may have been cancelled - * while we switched locks. - */ - if (cc->cc_cancel) { - class->lc_unlock(c_lock); - goto skip; - } - /* The callout cannot be stopped now. */ - cc->cc_cancel = 1; - - if (c_lock == &Giant.lock_object) { - gcalls++; - CTR3(KTR_CALLOUT, - "callout %p func %p arg %p", - c, c_func, c_arg); - } else { - lockcalls++; - CTR3(KTR_CALLOUT, "callout lock" - " %p func %p arg %p", - c, c_func, c_arg); - } - } else { - mpcalls++; - CTR3(KTR_CALLOUT, - "callout mpsafe %p func %p arg %p", - c, c_func, c_arg); - } -#ifdef DIAGNOSTIC - binuptime(&bt1); -#endif - THREAD_NO_SLEEPING(); - SDT_PROBE(callout_execute, kernel, , - callout_start, c, 0, 0, 0, 0); - c_func(c_arg); - SDT_PROBE(callout_execute, kernel, , - callout_end, c, 0, 0, 0, 0); - THREAD_SLEEPING_OK(); -#ifdef DIAGNOSTIC - binuptime(&bt2); - bintime_sub(&bt2, &bt1); - if (bt2.frac > maxdt) { - if (lastfunc != c_func || - bt2.frac > maxdt * 2) { - bintime2timespec(&bt2, &ts2); - printf( - "Expensive timeout(9) function: %p(%p) %jd.%09ld s\n", - c_func, c_arg, - (intmax_t)ts2.tv_sec, - ts2.tv_nsec); - } - maxdt = bt2.frac; - lastfunc = c_func; - } -#endif - CTR1(KTR_CALLOUT, "callout %p finished", c); - if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0) - class->lc_unlock(c_lock); - skip: - CC_LOCK(cc); - /* - * If the current callout is locally - * allocated (from timeout(9)) - * then put it on the freelist. - * - * Note: we need to check the cached - * copy of c_flags because if it was not - * local, then it's not safe to deref the - * callout pointer. - */ - if (c_flags & CALLOUT_LOCAL_ALLOC) { - KASSERT(c->c_flags == - CALLOUT_LOCAL_ALLOC, - ("corrupted callout")); - c->c_func = NULL; - SLIST_INSERT_HEAD(&cc->cc_callfree, c, - c_links.sle); - } - cc->cc_curr = NULL; - if (cc->cc_waiting) { - - /* - * There is someone waiting for the - * callout to complete. - * If the callout was scheduled for - * migration just cancel it. - */ - if (cc_cme_migrating(cc)) - cc_cme_cleanup(cc); - cc->cc_waiting = 0; - CC_UNLOCK(cc); - wakeup(&cc->cc_waiting); - CC_LOCK(cc); - } else if (cc_cme_migrating(cc)) { -#ifdef SMP - struct callout_cpu *new_cc; - void (*new_func)(void *); - void *new_arg; - int new_cpu, new_ticks; - - /* - * If the callout was scheduled for - * migration just perform it now. - */ - new_cpu = cc->cc_migration_cpu; - new_ticks = cc->cc_migration_ticks; - new_func = cc->cc_migration_func; - new_arg = cc->cc_migration_arg; - cc_cme_cleanup(cc); - - /* - * Handle deferred callout stops - */ - if ((c->c_flags & CALLOUT_DFRMIGRATION) - == 0) { - CTR3(KTR_CALLOUT, - "deferred cancelled %p func %p arg %p", - c, new_func, new_arg); - if (cc->cc_next == c) { - cc->cc_next = - TAILQ_NEXT(c, - c_links.tqe); - } - if (c->c_flags & - CALLOUT_LOCAL_ALLOC) { - c->c_func = NULL; - SLIST_INSERT_HEAD( - &cc->cc_callfree, c, - c_links.sle); - } - goto nextc; - } else { - c->c_flags &= ~ - CALLOUT_DFRMIGRATION; - } - - /* - * It should be assert here that the - * callout is not destroyed but that - * is not easy. - */ - new_cc = callout_cpu_switch(c, cc, - new_cpu); - callout_cc_add(c, new_cc, new_ticks, - new_func, new_arg, new_cpu); - CC_UNLOCK(new_cc); - CC_LOCK(cc); -#else - panic("migration should not happen"); -#endif - } -#ifdef SMP -nextc: -#endif + c = softclock_call_cc(c, cc, &mpcalls, + &lockcalls, &gcalls); steps = 0; - c = cc->cc_next; } } } @@ -1032,19 +1022,12 @@ again: c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); - if (cc->cc_next == c) { - cc->cc_next = TAILQ_NEXT(c, c_links.tqe); - } - TAILQ_REMOVE(&cc->cc_callwheel[c->c_time & callwheelmask], c, - c_links.tqe); - CTR3(KTR_CALLOUT, "cancelled %p func %p arg %p", c, c->c_func, c->c_arg); + TAILQ_REMOVE(&cc->cc_callwheel[c->c_time & callwheelmask], c, + c_links.tqe); + callout_cc_del(c, cc); - if (c->c_flags & CALLOUT_LOCAL_ALLOC) { - c->c_func = NULL; - SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle); - } CC_UNLOCK(cc); return (1); } From owner-svn-src-head@FreeBSD.ORG Thu May 3 20:41:22 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A07F9106564A; Thu, 3 May 2012 20:41:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 861488FC0A; Thu, 3 May 2012 20:41:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43KfMY8062066; Thu, 3 May 2012 20:41:22 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43KfMYu062048; Thu, 3 May 2012 20:41:22 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205032041.q43KfMYu062048@svn.freebsd.org> From: Dimitry Andric Date: Thu, 3 May 2012 20:41:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234982 - in head: contrib/llvm/include/llvm contrib/llvm/include/llvm-c contrib/llvm/include/llvm/ADT contrib/llvm/include/llvm/CodeGen contrib/llvm/include/llvm/MC/MCParser contrib/ll... X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 20:41:22 -0000 Author: dim Date: Thu May 3 20:41:21 2012 New Revision: 234982 URL: http://svn.freebsd.org/changeset/base/234982 Log: Upgrade our copy of llvm/clang to r155985, from upstream's release_31 branch. This brings us very close to the 3.1 release, which is planned for May 14th. MFC after: 2 weeks Added: head/contrib/llvm/include/llvm/Support/Locale.h - copied unchanged from r234974, vendor/llvm/dist/include/llvm/Support/Locale.h head/contrib/llvm/include/llvm/Support/MDBuilder.h - copied unchanged from r234974, vendor/llvm/dist/include/llvm/Support/MDBuilder.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp - copied unchanged from r234974, vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/GDBRegistrar.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/JITRegistrar.h - copied unchanged from r234974, vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/JITRegistrar.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImage.h - copied unchanged from r234974, vendor/llvm/dist/lib/ExecutionEngine/RuntimeDyld/ObjectImage.h head/contrib/llvm/lib/Support/Locale.cpp - copied unchanged from r234974, vendor/llvm/dist/lib/Support/Locale.cpp head/contrib/llvm/lib/Support/LocaleGeneric.inc - copied unchanged from r234974, vendor/llvm/dist/lib/Support/LocaleGeneric.inc head/contrib/llvm/lib/Support/LocaleWindows.inc - copied unchanged from r234974, vendor/llvm/dist/lib/Support/LocaleWindows.inc head/contrib/llvm/lib/Support/LocaleXlocale.inc - copied unchanged from r234974, vendor/llvm/dist/lib/Support/LocaleXlocale.inc head/contrib/llvm/lib/Target/Mips/Disassembler/ - copied from r234974, vendor/llvm/dist/lib/Target/Mips/Disassembler/ head/contrib/llvm/tools/clang/lib/Sema/SemaStmtAttr.cpp - copied unchanged from r234977, vendor/clang/dist/lib/Sema/SemaStmtAttr.cpp Deleted: head/contrib/llvm/include/llvm/Support/JSONParser.h head/contrib/llvm/lib/Support/JSONParser.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonMCInst.h head/contrib/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp head/contrib/llvm/lib/Target/Mips/Disassembler/CMakeLists.txt head/contrib/llvm/lib/Target/Mips/Disassembler/LLVMBuild.txt head/contrib/llvm/lib/Target/Mips/Disassembler/Makefile head/contrib/llvm/tools/clang/include/clang/Basic/DelayedCleanupPool.h head/contrib/llvm/tools/clang/include/clang/Index/ head/contrib/llvm/tools/clang/lib/Index/ head/lib/clang/libclangindex/ Modified: head/contrib/llvm/include/llvm-c/lto.h head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h head/contrib/llvm/include/llvm/ADT/StringMap.h head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h head/contrib/llvm/include/llvm/CodeGen/Passes.h head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h head/contrib/llvm/include/llvm/IntrinsicsX86.td head/contrib/llvm/include/llvm/LLVMContext.h head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h head/contrib/llvm/include/llvm/Object/ELF.h head/contrib/llvm/include/llvm/Operator.h head/contrib/llvm/include/llvm/Support/IRBuilder.h head/contrib/llvm/include/llvm/Support/Process.h head/contrib/llvm/include/llvm/Support/SourceMgr.h head/contrib/llvm/include/llvm/Support/YAMLParser.h head/contrib/llvm/include/llvm/Support/raw_ostream.h head/contrib/llvm/include/llvm/TableGen/Error.h head/contrib/llvm/include/llvm/TableGen/Record.h head/contrib/llvm/include/llvm/Target/TargetLibraryInfo.h head/contrib/llvm/include/llvm/Target/TargetRegisterInfo.h head/contrib/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h head/contrib/llvm/include/llvm/Transforms/Vectorize.h head/contrib/llvm/lib/Analysis/ConstantFolding.cpp head/contrib/llvm/lib/Analysis/ScalarEvolution.cpp head/contrib/llvm/lib/Analysis/ValueTracking.cpp head/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp head/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.h head/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp head/contrib/llvm/lib/CodeGen/DFAPacketizer.cpp head/contrib/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp head/contrib/llvm/lib/CodeGen/MachineBasicBlock.cpp head/contrib/llvm/lib/CodeGen/MachineBlockPlacement.cpp head/contrib/llvm/lib/CodeGen/Passes.cpp head/contrib/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp head/contrib/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp head/contrib/llvm/lib/CodeGen/SlotIndexes.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp head/contrib/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h head/contrib/llvm/lib/MC/MCParser/AsmParser.cpp head/contrib/llvm/lib/Object/ELFObjectFile.cpp head/contrib/llvm/lib/Support/SmallPtrSet.cpp head/contrib/llvm/lib/Support/SourceMgr.cpp head/contrib/llvm/lib/Support/Unix/Process.inc head/contrib/llvm/lib/Support/Windows/Process.inc head/contrib/llvm/lib/Support/YAMLParser.cpp head/contrib/llvm/lib/Support/raw_ostream.cpp head/contrib/llvm/lib/TableGen/Error.cpp head/contrib/llvm/lib/Target/ARM/ARMCallingConv.td head/contrib/llvm/lib/Target/ARM/ARMInstrFormats.td head/contrib/llvm/lib/Target/ARM/ARMInstrInfo.td head/contrib/llvm/lib/Target/ARM/ARMInstrNEON.td head/contrib/llvm/lib/Target/ARM/ARMTargetMachine.cpp head/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp head/contrib/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp head/contrib/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp head/contrib/llvm/lib/Target/CellSPU/SPUCallingConv.td head/contrib/llvm/lib/Target/CellSPU/SPUTargetMachine.cpp head/contrib/llvm/lib/Target/Hexagon/Hexagon.h head/contrib/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonInstrFormats.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrFormatsV4.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfo.h head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfo.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfoV3.td head/contrib/llvm/lib/Target/Hexagon/HexagonInstrInfoV4.td head/contrib/llvm/lib/Target/Hexagon/HexagonMCInstLower.cpp head/contrib/llvm/lib/Target/Hexagon/HexagonSchedule.td head/contrib/llvm/lib/Target/Hexagon/HexagonScheduleV4.td head/contrib/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp head/contrib/llvm/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.cpp head/contrib/llvm/lib/Target/Hexagon/InstPrinter/HexagonInstPrinter.h head/contrib/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonBaseInfo.h head/contrib/llvm/lib/Target/MBlaze/MBlazeCallingConv.td head/contrib/llvm/lib/Target/MBlaze/MBlazeTargetMachine.cpp head/contrib/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp head/contrib/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp head/contrib/llvm/lib/Target/Mips/Mips64InstrInfo.td head/contrib/llvm/lib/Target/Mips/MipsCondMov.td head/contrib/llvm/lib/Target/Mips/MipsISelLowering.cpp head/contrib/llvm/lib/Target/Mips/MipsInstrFPU.td head/contrib/llvm/lib/Target/Mips/MipsInstrFormats.td head/contrib/llvm/lib/Target/Mips/MipsInstrInfo.td head/contrib/llvm/lib/Target/Mips/MipsTargetMachine.cpp head/contrib/llvm/lib/Target/PTX/PTXTargetMachine.cpp head/contrib/llvm/lib/Target/PowerPC/PPCCallingConv.td head/contrib/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp head/contrib/llvm/lib/Target/Sparc/SparcTargetMachine.cpp head/contrib/llvm/lib/Target/TargetLibraryInfo.cpp head/contrib/llvm/lib/Target/X86/Utils/X86ShuffleDecode.cpp head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp head/contrib/llvm/lib/Target/X86/X86ISelLowering.h head/contrib/llvm/lib/Target/X86/X86InstrFragmentsSIMD.td head/contrib/llvm/lib/Target/X86/X86InstrInfo.cpp head/contrib/llvm/lib/Target/X86/X86InstrSSE.td head/contrib/llvm/lib/Target/X86/X86Subtarget.cpp head/contrib/llvm/lib/Target/X86/X86TargetMachine.cpp head/contrib/llvm/lib/Target/XCore/XCoreTargetMachine.cpp head/contrib/llvm/lib/Transforms/IPO/Internalize.cpp head/contrib/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp head/contrib/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp head/contrib/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp head/contrib/llvm/lib/Transforms/Scalar/ObjCARC.cpp head/contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp head/contrib/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp head/contrib/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp head/contrib/llvm/lib/Transforms/Vectorize/BBVectorize.cpp head/contrib/llvm/lib/VMCore/AutoUpgrade.cpp head/contrib/llvm/lib/VMCore/Instructions.cpp head/contrib/llvm/lib/VMCore/LLVMContext.cpp head/contrib/llvm/lib/VMCore/Module.cpp head/contrib/llvm/lib/VMCore/Verifier.cpp head/contrib/llvm/tools/clang/include/clang/AST/Decl.h head/contrib/llvm/tools/clang/include/clang/AST/DeclBase.h head/contrib/llvm/tools/clang/include/clang/AST/DeclLookups.h head/contrib/llvm/tools/clang/include/clang/AST/Expr.h head/contrib/llvm/tools/clang/include/clang/AST/ExternalASTSource.h head/contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h head/contrib/llvm/tools/clang/include/clang/AST/Stmt.h head/contrib/llvm/tools/clang/include/clang/AST/Type.h head/contrib/llvm/tools/clang/include/clang/AST/VTableBuilder.h head/contrib/llvm/tools/clang/include/clang/Analysis/ProgramPoint.h head/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def head/contrib/llvm/tools/clang/include/clang/Basic/ConvertUTF.h head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td head/contrib/llvm/tools/clang/include/clang/Basic/ExceptionSpecificationType.h head/contrib/llvm/tools/clang/include/clang/Basic/OnDiskHashTable.h head/contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td head/contrib/llvm/tools/clang/include/clang/Basic/TargetInfo.h head/contrib/llvm/tools/clang/include/clang/Basic/TokenKinds.def head/contrib/llvm/tools/clang/include/clang/Driver/CC1Options.td head/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h head/contrib/llvm/tools/clang/include/clang/Frontend/ASTUnit.h head/contrib/llvm/tools/clang/include/clang/Frontend/FrontendActions.h head/contrib/llvm/tools/clang/include/clang/Frontend/FrontendOptions.h head/contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnostic.h head/contrib/llvm/tools/clang/include/clang/Parse/Parser.h head/contrib/llvm/tools/clang/include/clang/Sema/DeclSpec.h head/contrib/llvm/tools/clang/include/clang/Sema/ParsedTemplate.h head/contrib/llvm/tools/clang/include/clang/Sema/Scope.h head/contrib/llvm/tools/clang/include/clang/Sema/Sema.h head/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h head/contrib/llvm/tools/clang/include/clang/Serialization/ASTReader.h head/contrib/llvm/tools/clang/include/clang/Serialization/ASTWriter.h head/contrib/llvm/tools/clang/include/clang/Serialization/Module.h head/contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h head/contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h head/contrib/llvm/tools/clang/include/clang/Tooling/CompilationDatabase.h head/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp head/contrib/llvm/tools/clang/lib/AST/Decl.cpp head/contrib/llvm/tools/clang/lib/AST/Expr.cpp head/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp head/contrib/llvm/tools/clang/lib/AST/ExternalASTSource.cpp head/contrib/llvm/tools/clang/lib/AST/ItaniumMangle.cpp head/contrib/llvm/tools/clang/lib/AST/Stmt.cpp head/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp head/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp head/contrib/llvm/tools/clang/lib/AST/Type.cpp head/contrib/llvm/tools/clang/lib/AST/VTableBuilder.cpp head/contrib/llvm/tools/clang/lib/Analysis/CFG.cpp head/contrib/llvm/tools/clang/lib/Basic/TargetInfo.cpp head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp head/contrib/llvm/tools/clang/lib/Basic/Version.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGBlocks.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGCall.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExpr.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExprAgg.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGExprConstant.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenTBAA.cpp head/contrib/llvm/tools/clang/lib/CodeGen/CodeGenTBAA.h head/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp head/contrib/llvm/tools/clang/lib/Driver/Compilation.cpp head/contrib/llvm/tools/clang/lib/Driver/Driver.cpp head/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp head/contrib/llvm/tools/clang/lib/Frontend/ASTUnit.cpp head/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp head/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp head/contrib/llvm/tools/clang/lib/Frontend/FrontendActions.cpp head/contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp head/contrib/llvm/tools/clang/lib/Frontend/TextDiagnostic.cpp head/contrib/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp head/contrib/llvm/tools/clang/lib/Headers/avx2intrin.h head/contrib/llvm/tools/clang/lib/Headers/avxintrin.h head/contrib/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp head/contrib/llvm/tools/clang/lib/Parse/ParseTemplate.cpp head/contrib/llvm/tools/clang/lib/Parse/Parser.cpp head/contrib/llvm/tools/clang/lib/Rewrite/RewriteModernObjC.cpp head/contrib/llvm/tools/clang/lib/Rewrite/RewriteRope.cpp head/contrib/llvm/tools/clang/lib/Sema/DeclSpec.cpp head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaAccess.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExceptionSpec.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExpr.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaExprMember.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaLookup.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaPseudoObject.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateDeduction.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp head/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp head/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h head/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderInternals.h head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp head/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp head/contrib/llvm/tools/clang/lib/Serialization/Module.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp head/contrib/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp head/contrib/llvm/tools/clang/lib/Tooling/CompilationDatabase.cpp head/contrib/llvm/tools/llc/llc.cpp head/contrib/llvm/tools/lli/lli.cpp head/contrib/llvm/tools/llvm-mc/Disassembler.cpp head/contrib/llvm/tools/llvm-mc/Disassembler.h head/contrib/llvm/tools/llvm-mc/llvm-mc.cpp head/contrib/llvm/tools/llvm-stress/llvm-stress.cpp head/contrib/llvm/tools/opt/opt.cpp head/contrib/llvm/utils/TableGen/AsmMatcherEmitter.cpp head/contrib/llvm/utils/TableGen/AsmWriterEmitter.cpp head/contrib/llvm/utils/TableGen/CodeGenDAGPatterns.cpp head/contrib/llvm/utils/TableGen/CodeGenRegisters.cpp head/contrib/llvm/utils/TableGen/EDEmitter.cpp head/contrib/llvm/utils/TableGen/RegisterInfoEmitter.cpp head/lib/clang/Makefile head/lib/clang/clang.build.mk head/lib/clang/include/clang/Basic/Version.inc head/lib/clang/include/clang/Config/config.h head/lib/clang/include/llvm/Config/config.h head/lib/clang/libclangsema/Makefile head/lib/clang/libllvmruntimedyld/Makefile head/lib/clang/libllvmsupport/Makefile head/usr.bin/clang/clang/Makefile Directory Properties: head/contrib/llvm/ (props changed) head/contrib/llvm/tools/clang/ (props changed) Modified: head/contrib/llvm/include/llvm-c/lto.h ============================================================================== --- head/contrib/llvm/include/llvm-c/lto.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm-c/lto.h Thu May 3 20:41:21 2012 (r234982) @@ -251,12 +251,6 @@ lto_codegen_set_assembler_args(lto_code_ int nargs); /** - * Enables the internalize pass during LTO optimizations. - */ -extern void -lto_codegen_set_whole_program_optimization(lto_code_gen_t cg); - -/** * Adds to a list of all global symbols that must exist in the final * generated code. If a function is not listed, it might be * inlined into every usage and optimized away. Modified: head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h ============================================================================== --- head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/ADT/SmallPtrSet.h Thu May 3 20:41:21 2012 (r234982) @@ -126,9 +126,6 @@ protected: private: bool isSmall() const { return CurArray == SmallArray; } - unsigned Hash(const void *Ptr) const { - return static_cast(((uintptr_t)Ptr >> 4) & (CurArraySize-1)); - } const void * const *FindBucketFor(const void *Ptr) const; void shrink_and_clear(); Modified: head/contrib/llvm/include/llvm/ADT/StringMap.h ============================================================================== --- head/contrib/llvm/include/llvm/ADT/StringMap.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/ADT/StringMap.h Thu May 3 20:41:21 2012 (r234982) @@ -239,7 +239,7 @@ public: explicit StringMap(AllocatorTy A) : StringMapImpl(static_cast(sizeof(MapEntryTy))), Allocator(A) {} - explicit StringMap(const StringMap &RHS) + StringMap(const StringMap &RHS) : StringMapImpl(static_cast(sizeof(MapEntryTy))) { assert(RHS.empty() && "Copy ctor from non-empty stringmap not implemented yet!"); Modified: head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/DFAPacketizer.h Thu May 3 20:41:21 2012 (r234982) @@ -28,7 +28,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/ADT/DenseMap.h" -#include namespace llvm { @@ -37,7 +36,7 @@ class MachineInstr; class MachineLoopInfo; class MachineDominatorTree; class InstrItineraryData; -class DefaultVLIWScheduler; +class ScheduleDAGInstrs; class SUnit; class DFAPacketizer { @@ -78,8 +77,6 @@ public: // reserveResources - Reserve the resources occupied by a machine // instruction and change the current state to reflect that change. void reserveResources(llvm::MachineInstr *MI); - - const InstrItineraryData *getInstrItins() const { return InstrItins; } }; // VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The @@ -90,21 +87,20 @@ public: // and machine resource is marked as taken. If any dependency is found, a target // API call is made to prune the dependence. class VLIWPacketizerList { -protected: const TargetMachine &TM; const MachineFunction &MF; const TargetInstrInfo *TII; - // The VLIW Scheduler. - DefaultVLIWScheduler *VLIWScheduler; + // Encapsulate data types not exposed to the target interface. + ScheduleDAGInstrs *SchedulerImpl; +protected: // Vector of instructions assigned to the current packet. std::vector CurrentPacketMIs; // DFA resource tracker. DFAPacketizer *ResourceTracker; - - // Generate MI -> SU map. - std::map MIToSUnit; + // Scheduling units. + std::vector SUnits; public: VLIWPacketizerList( @@ -122,32 +118,17 @@ public: DFAPacketizer *getResourceTracker() {return ResourceTracker;} // addToPacket - Add MI to the current packet. - virtual MachineBasicBlock::iterator addToPacket(MachineInstr *MI) { - MachineBasicBlock::iterator MII = MI; - CurrentPacketMIs.push_back(MI); - ResourceTracker->reserveResources(MI); - return MII; - } + void addToPacket(MachineInstr *MI); // endPacket - End the current packet. - void endPacket(MachineBasicBlock *MBB, MachineInstr *MI); - - // initPacketizerState - perform initialization before packetizing - // an instruction. This function is supposed to be overrided by - // the target dependent packetizer. - virtual void initPacketizerState(void) { return; } + void endPacket(MachineBasicBlock *MBB, MachineInstr *I); // ignorePseudoInstruction - Ignore bundling of pseudo instructions. - virtual bool ignorePseudoInstruction(MachineInstr *I, - MachineBasicBlock *MBB) { - return false; - } + bool ignorePseudoInstruction(MachineInstr *I, MachineBasicBlock *MBB); - // isSoloInstruction - return true if instruction MI can not be packetized - // with any other instruction, which means that MI itself is a packet. - virtual bool isSoloInstruction(MachineInstr *MI) { - return true; - } + // isSoloInstruction - return true if instruction I must end previous + // packet. + bool isSoloInstruction(MachineInstr *I); // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ // together. @@ -160,7 +141,6 @@ public: virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) { return false; } - }; } Modified: head/contrib/llvm/include/llvm/CodeGen/Passes.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/Passes.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/Passes.h Thu May 3 20:41:21 2012 (r234982) @@ -56,7 +56,7 @@ public: protected: TargetMachine *TM; - PassManagerBase &PM; + PassManagerBase *PM; PassConfigImpl *Impl; // Internal data structures bool Initialized; // Flagged after all passes are configured. Modified: head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/ScheduleDAGInstrs.h Thu May 3 20:41:21 2012 (r234982) @@ -181,6 +181,13 @@ namespace llvm { /// the def-side latency only. bool UnitLatencies; + /// The standard DAG builder does not normally include terminators as DAG + /// nodes because it does not create the necessary dependencies to prevent + /// reordering. A specialized scheduler can overide + /// TargetInstrInfo::isSchedulingBoundary then enable this flag to indicate + /// it has taken responsibility for scheduling the terminator correctly. + bool CanHandleTerminators; + /// State specific to the current scheduling region. /// ------------------------------------------------ Modified: head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h ============================================================================== --- head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h Thu May 3 20:41:21 2012 (r234982) @@ -23,6 +23,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/ilist.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Allocator.h" @@ -33,8 +34,7 @@ namespace llvm { /// SlotIndexes pass. It should not be used directly. See the /// SlotIndex & SlotIndexes classes for the public interface to this /// information. - class IndexListEntry { - IndexListEntry *next, *prev; + class IndexListEntry : public ilist_node { MachineInstr *mi; unsigned index; @@ -51,31 +51,26 @@ namespace llvm { void setIndex(unsigned index) { this->index = index; } - - IndexListEntry* getNext() { return next; } - const IndexListEntry* getNext() const { return next; } - void setNext(IndexListEntry *next) { - this->next = next; - } - IndexListEntry* getPrev() { return prev; } - const IndexListEntry* getPrev() const { return prev; } - void setPrev(IndexListEntry *prev) { - this->prev = prev; - } }; - // Specialize PointerLikeTypeTraits for IndexListEntry. template <> - class PointerLikeTypeTraits { + struct ilist_traits : public ilist_default_traits { + private: + mutable ilist_half_node Sentinel; public: - static inline void* getAsVoidPointer(IndexListEntry *p) { - return p; + IndexListEntry *createSentinel() const { + return static_cast(&Sentinel); } - static inline IndexListEntry* getFromVoidPointer(void *p) { - return static_cast(p); - } - enum { NumLowBitsAvailable = 3 }; + void destroySentinel(IndexListEntry *) const {} + + IndexListEntry *provideInitialHead() const { return createSentinel(); } + IndexListEntry *ensureHead(IndexListEntry*) const { return createSentinel(); } + static void noteHead(IndexListEntry*, IndexListEntry*) {} + void deleteNode(IndexListEntry *N) {} + + private: + void createNode(const IndexListEntry &); }; /// SlotIndex - An opaque wrapper around machine indexes. @@ -112,13 +107,13 @@ namespace llvm { SlotIndex(IndexListEntry *entry, unsigned slot) : lie(entry, slot) {} - IndexListEntry& entry() const { + IndexListEntry* listEntry() const { assert(isValid() && "Attempt to compare reserved index."); - return *lie.getPointer(); + return lie.getPointer(); } int getIndex() const { - return entry().getIndex() | getSlot(); + return listEntry()->getIndex() | getSlot(); } /// Returns the slot for this SlotIndex. @@ -150,8 +145,7 @@ namespace llvm { SlotIndex() : lie(0, 0) {} // Construct a new slot index from the given one, and set the slot. - SlotIndex(const SlotIndex &li, Slot s) - : lie(&li.entry(), unsigned(s)) { + SlotIndex(const SlotIndex &li, Slot s) : lie(li.listEntry(), unsigned(s)) { assert(lie.getPointer() != 0 && "Attempt to construct index with 0 pointer."); } @@ -179,7 +173,7 @@ namespace llvm { bool operator!=(SlotIndex other) const { return lie != other.lie; } - + /// Compare two SlotIndex objects. Return true if the first index /// is strictly lower than the second. bool operator<(SlotIndex other) const { @@ -211,7 +205,7 @@ namespace llvm { /// isEarlierInstr - Return true if A refers to an instruction earlier than /// B. This is equivalent to A < B && !isSameInstr(A, B). static bool isEarlierInstr(SlotIndex A, SlotIndex B) { - return A.entry().getIndex() < B.entry().getIndex(); + return A.listEntry()->getIndex() < B.listEntry()->getIndex(); } /// Return the distance from this index to the given one. @@ -236,25 +230,25 @@ namespace llvm { /// is the one associated with the Slot_Block slot for the instruction /// pointed to by this index. SlotIndex getBaseIndex() const { - return SlotIndex(&entry(), Slot_Block); + return SlotIndex(listEntry(), Slot_Block); } /// Returns the boundary index for associated with this index. The boundary /// index is the one associated with the Slot_Block slot for the instruction /// pointed to by this index. SlotIndex getBoundaryIndex() const { - return SlotIndex(&entry(), Slot_Dead); + return SlotIndex(listEntry(), Slot_Dead); } /// Returns the register use/def slot in the current instruction for a /// normal or early-clobber def. SlotIndex getRegSlot(bool EC = false) const { - return SlotIndex(&entry(), EC ? Slot_EarlyClobber : Slot_Register); + return SlotIndex(listEntry(), EC ? Slot_EarlyClobber : Slot_Register); } /// Returns the dead def kill slot for the current instruction. SlotIndex getDeadSlot() const { - return SlotIndex(&entry(), Slot_Dead); + return SlotIndex(listEntry(), Slot_Dead); } /// Returns the next slot in the index list. This could be either the @@ -266,15 +260,15 @@ namespace llvm { SlotIndex getNextSlot() const { Slot s = getSlot(); if (s == Slot_Dead) { - return SlotIndex(entry().getNext(), Slot_Block); + return SlotIndex(listEntry()->getNextNode(), Slot_Block); } - return SlotIndex(&entry(), s + 1); + return SlotIndex(listEntry(), s + 1); } /// Returns the next index. This is the index corresponding to the this /// index's slot, but for the next instruction. SlotIndex getNextIndex() const { - return SlotIndex(entry().getNext(), getSlot()); + return SlotIndex(listEntry()->getNextNode(), getSlot()); } /// Returns the previous slot in the index list. This could be either the @@ -286,15 +280,15 @@ namespace llvm { SlotIndex getPrevSlot() const { Slot s = getSlot(); if (s == Slot_Block) { - return SlotIndex(entry().getPrev(), Slot_Dead); + return SlotIndex(listEntry()->getPrevNode(), Slot_Dead); } - return SlotIndex(&entry(), s - 1); + return SlotIndex(listEntry(), s - 1); } /// Returns the previous index. This is the index corresponding to this /// index's slot, but for the previous instruction. SlotIndex getPrevIndex() const { - return SlotIndex(entry().getPrev(), getSlot()); + return SlotIndex(listEntry()->getPrevNode(), getSlot()); } }; @@ -315,7 +309,7 @@ namespace llvm { return (LHS == RHS); } }; - + template <> struct isPodLike { static const bool value = true; }; @@ -346,8 +340,10 @@ namespace llvm { class SlotIndexes : public MachineFunctionPass { private: + typedef ilist IndexList; + IndexList indexList; + MachineFunction *mf; - IndexListEntry *indexListHead; unsigned functionSize; typedef DenseMap Mi2IndexMap; @@ -374,84 +370,18 @@ namespace llvm { return entry; } - void initList() { - assert(indexListHead == 0 && "Zero entry non-null at initialisation."); - indexListHead = createEntry(0, ~0U); - indexListHead->setNext(0); - indexListHead->setPrev(indexListHead); - } - - void clearList() { - indexListHead = 0; - ileAllocator.Reset(); - } - - IndexListEntry* getTail() { - assert(indexListHead != 0 && "Call to getTail on uninitialized list."); - return indexListHead->getPrev(); - } - - const IndexListEntry* getTail() const { - assert(indexListHead != 0 && "Call to getTail on uninitialized list."); - return indexListHead->getPrev(); - } - - // Returns true if the index list is empty. - bool empty() const { return (indexListHead == getTail()); } - - IndexListEntry* front() { - assert(!empty() && "front() called on empty index list."); - return indexListHead; - } - - const IndexListEntry* front() const { - assert(!empty() && "front() called on empty index list."); - return indexListHead; - } - - IndexListEntry* back() { - assert(!empty() && "back() called on empty index list."); - return getTail()->getPrev(); - } - - const IndexListEntry* back() const { - assert(!empty() && "back() called on empty index list."); - return getTail()->getPrev(); - } - - /// Insert a new entry before itr. - void insert(IndexListEntry *itr, IndexListEntry *val) { - assert(itr != 0 && "itr should not be null."); - IndexListEntry *prev = itr->getPrev(); - val->setNext(itr); - val->setPrev(prev); - - if (itr != indexListHead) { - prev->setNext(val); - } - else { - indexListHead = val; - } - itr->setPrev(val); - } - - /// Push a new entry on to the end of the list. - void push_back(IndexListEntry *val) { - insert(getTail(), val); - } - - /// Renumber locally after inserting newEntry. - void renumberIndexes(IndexListEntry *newEntry); + /// Renumber locally after inserting curItr. + void renumberIndexes(IndexList::iterator curItr); public: static char ID; - SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) { + SlotIndexes() : MachineFunctionPass(ID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); } virtual void getAnalysisUsage(AnalysisUsage &au) const; - virtual void releaseMemory(); + virtual void releaseMemory(); virtual bool runOnMachineFunction(MachineFunction &fn); @@ -463,22 +393,21 @@ namespace llvm { /// Returns the zero index for this analysis. SlotIndex getZeroIndex() { - assert(front()->getIndex() == 0 && "First index is not 0?"); - return SlotIndex(front(), 0); + assert(indexList.front().getIndex() == 0 && "First index is not 0?"); + return SlotIndex(&indexList.front(), 0); } /// Returns the base index of the last slot in this analysis. SlotIndex getLastIndex() { - return SlotIndex(back(), 0); + return SlotIndex(&indexList.back(), 0); } /// Returns the distance between the highest and lowest indexes allocated /// so far. unsigned getIndexesLength() const { - assert(front()->getIndex() == 0 && + assert(indexList.front().getIndex() == 0 && "Initial index isn't zero?"); - - return back()->getIndex(); + return indexList.back().getIndex(); } /// Returns the number of instructions in the function. @@ -503,19 +432,15 @@ namespace llvm { /// Returns the instruction for the given index, or null if the given /// index has no instruction associated with it. MachineInstr* getInstructionFromIndex(SlotIndex index) const { - return index.isValid() ? index.entry().getInstr() : 0; + return index.isValid() ? index.listEntry()->getInstr() : 0; } /// Returns the next non-null index. SlotIndex getNextNonNullIndex(SlotIndex index) { - SlotIndex nextNonNull = index.getNextIndex(); - - while (&nextNonNull.entry() != getTail() && - getInstructionFromIndex(nextNonNull) == 0) { - nextNonNull = nextNonNull.getNextIndex(); - } - - return nextNonNull; + IndexList::iterator itr(index.listEntry()); + ++itr; + while (itr != indexList.end() && itr->getInstr() == 0) { ++itr; } + return SlotIndex(itr, index.getSlot()); } /// getIndexBefore - Returns the index of the last indexed instruction @@ -659,31 +584,31 @@ namespace llvm { assert(mi->getParent() != 0 && "Instr must be added to function."); // Get the entries where mi should be inserted. - IndexListEntry *prevEntry, *nextEntry; + IndexList::iterator prevItr, nextItr; if (Late) { // Insert mi's index immediately before the following instruction. - nextEntry = &getIndexAfter(mi).entry(); - prevEntry = nextEntry->getPrev(); + nextItr = getIndexAfter(mi).listEntry(); + prevItr = prior(nextItr); } else { // Insert mi's index immediately after the preceeding instruction. - prevEntry = &getIndexBefore(mi).entry(); - nextEntry = prevEntry->getNext(); + prevItr = getIndexBefore(mi).listEntry(); + nextItr = llvm::next(prevItr); } // Get a number for the new instr, or 0 if there's no room currently. // In the latter case we'll force a renumber later. - unsigned dist = ((nextEntry->getIndex() - prevEntry->getIndex())/2) & ~3u; - unsigned newNumber = prevEntry->getIndex() + dist; + unsigned dist = ((nextItr->getIndex() - prevItr->getIndex())/2) & ~3u; + unsigned newNumber = prevItr->getIndex() + dist; // Insert a new list entry for mi. - IndexListEntry *newEntry = createEntry(mi, newNumber); - insert(nextEntry, newEntry); + IndexList::iterator newItr = + indexList.insert(nextItr, createEntry(mi, newNumber)); // Renumber locally if we need to. if (dist == 0) - renumberIndexes(newEntry); + renumberIndexes(newItr); - SlotIndex newIndex(newEntry, SlotIndex::Slot_Block); + SlotIndex newIndex(&*newItr, SlotIndex::Slot_Block); mi2iMap.insert(std::make_pair(mi, newIndex)); return newIndex; } @@ -694,7 +619,7 @@ namespace llvm { // MachineInstr -> index mappings Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi); if (mi2iItr != mi2iMap.end()) { - IndexListEntry *miEntry(&mi2iItr->second.entry()); + IndexListEntry *miEntry(mi2iItr->second.listEntry()); assert(miEntry->getInstr() == mi && "Instruction indexes broken."); // FIXME: Eventually we want to actually delete these indexes. miEntry->setInstr(0); @@ -709,7 +634,7 @@ namespace llvm { if (mi2iItr == mi2iMap.end()) return; SlotIndex replaceBaseIndex = mi2iItr->second; - IndexListEntry *miEntry(&replaceBaseIndex.entry()); + IndexListEntry *miEntry(replaceBaseIndex.listEntry()); assert(miEntry->getInstr() == mi && "Mismatched instruction in index tables."); miEntry->setInstr(newMI); @@ -726,13 +651,13 @@ namespace llvm { IndexListEntry *nextEntry = 0; if (nextMBB == mbb->getParent()->end()) { - nextEntry = getTail(); + nextEntry = indexList.end(); } else { - nextEntry = &getMBBStartIdx(nextMBB).entry(); + nextEntry = getMBBStartIdx(nextMBB).listEntry(); } - insert(nextEntry, startEntry); - insert(nextEntry, stopEntry); + indexList.insert(nextEntry, startEntry); + indexList.insert(nextEntry, stopEntry); SlotIndex startIdx(startEntry, SlotIndex::Slot_Block); SlotIndex endIdx(nextEntry, SlotIndex::Slot_Block); @@ -766,4 +691,4 @@ namespace llvm { } -#endif // LLVM_CODEGEN_LIVEINDEX_H +#endif // LLVM_CODEGEN_SLOTINDEXES_H Modified: head/contrib/llvm/include/llvm/IntrinsicsX86.td ============================================================================== --- head/contrib/llvm/include/llvm/IntrinsicsX86.td Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/IntrinsicsX86.td Thu May 3 20:41:21 2012 (r234982) @@ -1091,20 +1091,6 @@ let TargetPrefix = "x86" in { // All in GCCBuiltin<"__builtin_ia32_vperm2f128_si256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>; - - def int_x86_avx_vpermil_pd : - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, - llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_vpermil_ps : - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, - llvm_i8_ty], [IntrNoMem]>; - - def int_x86_avx_vpermil_pd_256 : - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_vpermil_ps_256 : - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_i8_ty], [IntrNoMem]>; } // Vector blend @@ -1659,15 +1645,9 @@ let TargetPrefix = "x86" in { // All in def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty], [IntrNoMem]>; - def int_x86_avx2_permq : GCCBuiltin<"__builtin_ia32_permdi256">, - Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx2_permpd : GCCBuiltin<"__builtin_ia32_permdf256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">, Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>; Modified: head/contrib/llvm/include/llvm/LLVMContext.h ============================================================================== --- head/contrib/llvm/include/llvm/LLVMContext.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/LLVMContext.h Thu May 3 20:41:21 2012 (r234982) @@ -42,7 +42,7 @@ public: MD_dbg = 0, // "dbg" MD_tbaa = 1, // "tbaa" MD_prof = 2, // "prof" - MD_fpaccuracy = 3, // "fpaccuracy" + MD_fpmath = 3, // "fpmath" MD_range = 4 // "range" }; Modified: head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h ============================================================================== --- head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/MC/MCParser/AsmLexer.h Thu May 3 20:41:21 2012 (r234982) @@ -16,14 +16,11 @@ #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCParser/MCAsmLexer.h" -#include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/DataTypes.h" #include -#include namespace llvm { class MemoryBuffer; -class SMLoc; class MCAsmInfo; /// AsmLexer - Lexer class for assembly files. Modified: head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h ============================================================================== --- head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/MC/MCParser/MCAsmLexer.h Thu May 3 20:41:21 2012 (r234982) @@ -15,8 +15,6 @@ #include "llvm/Support/SMLoc.h" namespace llvm { -class MCAsmLexer; -class MCInst; /// AsmToken - Target independent representation for an assembler token. class AsmToken { @@ -53,6 +51,7 @@ public: Greater, GreaterEqual, GreaterGreater, At }; +private: TokenKind Kind; /// A reference to the entire token contents; this is always a pointer into Modified: head/contrib/llvm/include/llvm/Object/ELF.h ============================================================================== --- head/contrib/llvm/include/llvm/Object/ELF.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/Object/ELF.h Thu May 3 20:41:21 2012 (r234982) @@ -33,6 +33,15 @@ namespace llvm { namespace object { +// Subclasses of ELFObjectFile may need this for template instantiation +inline std::pair +getElfArchType(MemoryBuffer *Object) { + if (Object->getBufferSize() < ELF::EI_NIDENT) + return std::make_pair((uint8_t)ELF::ELFCLASSNONE,(uint8_t)ELF::ELFDATANONE); + return std::make_pair( (uint8_t)Object->getBufferStart()[ELF::EI_CLASS] + , (uint8_t)Object->getBufferStart()[ELF::EI_DATA]); +} + // Templates to choose Elf_Addr and Elf_Off depending on is64Bits. template struct ELFDataTypeTypedefHelperCommon { Modified: head/contrib/llvm/include/llvm/Operator.h ============================================================================== --- head/contrib/llvm/include/llvm/Operator.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/Operator.h Thu May 3 20:41:21 2012 (r234982) @@ -15,8 +15,9 @@ #ifndef LLVM_OPERATOR_H #define LLVM_OPERATOR_H -#include "llvm/Instruction.h" #include "llvm/Constants.h" +#include "llvm/Instruction.h" +#include "llvm/Type.h" namespace llvm { @@ -129,14 +130,15 @@ public: IsExact = (1 << 0) }; +private: + ~PossiblyExactOperator(); // do not implement + friend class BinaryOperator; friend class ConstantExpr; void setIsExact(bool B) { SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact); } -private: - ~PossiblyExactOperator(); // do not implement public: /// isExact - Test whether this division is known to be exact, with /// zero remainder. @@ -161,7 +163,28 @@ public: (isa(V) && classof(cast(V))); } }; - + +/// FPMathOperator - Utility class for floating point operations which can have +/// information about relaxed accuracy requirements attached to them. +class FPMathOperator : public Operator { +private: + ~FPMathOperator(); // do not implement + +public: + + /// \brief Get the maximum error permitted by this operation in ULPs. An + /// accuracy of 0.0 means that the operation should be performed with the + /// default precision. + float getFPAccuracy() const; + + static inline bool classof(const FPMathOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getType()->isFPOrFPVectorTy(); + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; /// ConcreteOperator - A helper template for defining operators for individual Modified: head/contrib/llvm/include/llvm/Support/IRBuilder.h ============================================================================== --- head/contrib/llvm/include/llvm/Support/IRBuilder.h Thu May 3 20:00:30 2012 (r234981) +++ head/contrib/llvm/include/llvm/Support/IRBuilder.h Thu May 3 20:41:21 2012 (r234982) @@ -17,6 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/BasicBlock.h" +#include "llvm/LLVMContext.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" @@ -331,49 +332,63 @@ template > class IRBuilder : public IRBuilderBase, public Inserter { T Folder; + MDNode *DefaultFPMathTag; public: - IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter()) - : IRBuilderBase(C), Inserter(I), Folder(F) { + IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter(), + MDNode *FPMathTag = 0) + : IRBuilderBase(C), Inserter(I), Folder(F), DefaultFPMathTag(FPMathTag) { } - explicit IRBuilder(LLVMContext &C) : IRBuilderBase(C), Folder() { + explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = 0) : IRBuilderBase(C), + Folder(), DefaultFPMathTag(FPMathTag) { } - explicit IRBuilder(BasicBlock *TheBB, const T &F) - : IRBuilderBase(TheBB->getContext()), Folder(F) { + explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(F), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB); } - explicit IRBuilder(BasicBlock *TheBB) - : IRBuilderBase(TheBB->getContext()), Folder() { + explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB); } - explicit IRBuilder(Instruction *IP) - : IRBuilderBase(IP->getContext()), Folder() { + explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = 0) + : IRBuilderBase(IP->getContext()), Folder(), DefaultFPMathTag(FPMathTag) { SetInsertPoint(IP); SetCurrentDebugLocation(IP->getDebugLoc()); } - explicit IRBuilder(Use &U) - : IRBuilderBase(U->getContext()), Folder() { + explicit IRBuilder(Use &U, MDNode *FPMathTag = 0) + : IRBuilderBase(U->getContext()), Folder(), DefaultFPMathTag(FPMathTag) { SetInsertPoint(U); SetCurrentDebugLocation(cast(U.getUser())->getDebugLoc()); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) - : IRBuilderBase(TheBB->getContext()), Folder(F) { + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F, + MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(F), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB, IP); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) - : IRBuilderBase(TheBB->getContext()), Folder() { + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB, IP); } /// getFolder - Get the constant folder being used. const T &getFolder() { return Folder; } + /// getDefaultFPMathTag - Get the floating point math metadata being used. + MDNode *getDefaultFPMathTag() const { return DefaultFPMathTag; } + + /// SetDefaultFPMathTag - Set the floating point math metadata to be used. + void SetDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; } + /// isNamePreserving - Return true if this builder is configured to actually /// add the requested names to IR created through it. bool isNamePreserving() const { return preserveNames; } @@ -496,6 +511,14 @@ private: if (HasNSW) BO->setHasNoSignedWrap(); return BO; } + + Instruction *AddFPMathTag(Instruction *I, MDNode *FPMathTag) const { + if (!FPMathTag) + FPMathTag = DefaultFPMathTag; + if (FPMathTag) + I->setMetadata(LLVMContext::MD_fpmath, FPMathTag); + return I; + } public: Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -511,11 +534,13 @@ public: Value *CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateAdd(LHS, RHS, Name, true, false); } - Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFAdd(LC, RC), Name); - return Insert(BinaryOperator::CreateFAdd(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFAdd(LHS, RHS), + FPMathTag), Name); } Value *CreateSub(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -531,11 +556,13 @@ public: Value *CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateSub(LHS, RHS, Name, true, false); } - Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFSub(LC, RC), Name); - return Insert(BinaryOperator::CreateFSub(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFSub(LHS, RHS), + FPMathTag), Name); } Value *CreateMul(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -551,11 +578,13 @@ public: Value *CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateMul(LHS, RHS, Name, true, false); } - Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFMul(LC, RC), Name); - return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFMul(LHS, RHS), + FPMathTag), Name); } Value *CreateUDiv(Value *LHS, Value *RHS, const Twine &Name = "", bool isExact = false) { @@ -581,11 +610,13 @@ public: Value *CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateSDiv(LHS, RHS, Name, true); } - Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFDiv(LC, RC), Name); - return Insert(BinaryOperator::CreateFDiv(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFDiv(LHS, RHS), + FPMathTag), Name); } Value *CreateURem(Value *LHS, Value *RHS, const Twine &Name = "") { if (Constant *LC = dyn_cast(LHS)) @@ -599,11 +630,13 @@ public: return Insert(Folder.CreateSRem(LC, RC), Name); return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name); } - Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Insert(Folder.CreateFRem(LC, RC), Name); - return Insert(BinaryOperator::CreateFRem(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFRem(LHS, RHS), + FPMathTag), Name); } Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "", @@ -729,10 +762,10 @@ public: Value *CreateNUWNeg(Value *V, const Twine &Name = "") { return CreateNeg(V, Name, true, false); } - Value *CreateFNeg(Value *V, const Twine &Name = "") { + Value *CreateFNeg(Value *V, const Twine &Name = "", MDNode *FPMathTag = 0) { if (Constant *VC = dyn_cast(V)) return Insert(Folder.CreateFNeg(VC), Name); - return Insert(BinaryOperator::CreateFNeg(V), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFNeg(V), FPMathTag), Name); } Value *CreateNot(Value *V, const Twine &Name = "") { if (Constant *VC = dyn_cast(V)) Copied: head/contrib/llvm/include/llvm/Support/Locale.h (from r234974, vendor/llvm/dist/include/llvm/Support/Locale.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/include/llvm/Support/Locale.h Thu May 3 20:41:21 2012 (r234982, copy of r234974, vendor/llvm/dist/include/llvm/Support/Locale.h) @@ -0,0 +1,17 @@ +#ifndef LLVM_SUPPORT_LOCALE +#define LLVM_SUPPORT_LOCALE + +#include "llvm/ADT/StringRef.h" + +namespace llvm { +namespace sys { +namespace locale { + +int columnWidth(StringRef s); +bool isPrint(int c); + +} +} +} + +#endif // LLVM_SUPPORT_LOCALE Copied: head/contrib/llvm/include/llvm/Support/MDBuilder.h (from r234974, vendor/llvm/dist/include/llvm/Support/MDBuilder.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/include/llvm/Support/MDBuilder.h Thu May 3 20:41:21 2012 (r234982, copy of r234974, vendor/llvm/dist/include/llvm/Support/MDBuilder.h) @@ -0,0 +1,118 @@ +//===---- llvm/Support/MDBuilder.h - Builder for LLVM metadata --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the MDBuilder class, which is used as a convenient way to +// create LLVM metadata with a consistent and simplified interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_MDBUILDER_H +#define LLVM_SUPPORT_MDBUILDER_H + +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" +#include "llvm/Metadata.h" *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Thu May 3 20:50:56 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E113106564A; Thu, 3 May 2012 20:50:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 092178FC0C; Thu, 3 May 2012 20:50:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43Kot3F062502; Thu, 3 May 2012 20:50:55 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43KotAu062500; Thu, 3 May 2012 20:50:55 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205032050.q43KotAu062500@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 20:50:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234983 - head/release/picobsd/build X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 20:50:56 -0000 Author: luigi Date: Thu May 3 20:50:55 2012 New Revision: 234983 URL: http://svn.freebsd.org/changeset/base/234983 Log: Omit clang when building picobsd, it takes way too long. Also note that loader.conf support is incomplete. Modified: head/release/picobsd/build/picobsd Modified: head/release/picobsd/build/picobsd ============================================================================== --- head/release/picobsd/build/picobsd Thu May 3 20:41:21 2012 (r234982) +++ head/release/picobsd/build/picobsd Thu May 3 20:50:55 2012 (r234983) @@ -164,6 +164,7 @@ create_includes_and_libraries2() { # opt log "create_includes_and_libraries2() for ${SRC} $1" if [ ${OSVERSION} -ge 600000 ] ; then no="-DNO_CLEAN -DNO_PROFILE -DNO_GAMES -DNO_LIBC_R" # WITHOUT_CDDL=1" + no="$no -DWITHOUT_CLANG" else no="-DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R" fi @@ -882,7 +883,7 @@ fill_floppy_image() { log "Compress with kgzip and copy to floppy image" mkdir -p ${dst}/boot/kernel - # XXX update loader.conf + # XXX loader.conf does not work unless we also load the .4th files echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader" From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:03:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A5E6B1065670; Thu, 3 May 2012 21:03:21 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 907F58FC08; Thu, 3 May 2012 21:03:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43L3LaK063016; Thu, 3 May 2012 21:03:21 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43L3L74063014; Thu, 3 May 2012 21:03:21 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205032103.q43L3L74063014@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 21:03:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234984 - head/tools/tools/netrate/netsend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:03:21 -0000 Author: luigi Date: Thu May 3 21:03:21 2012 New Revision: 234984 URL: http://svn.freebsd.org/changeset/base/234984 Log: indicate the time per packet in nanoseconds. Modified: head/tools/tools/netrate/netsend/netsend.c Modified: head/tools/tools/netrate/netsend/netsend.c ============================================================================== --- head/tools/tools/netrate/netsend/netsend.c Thu May 3 20:50:55 2012 (r234983) +++ head/tools/tools/netrate/netsend/netsend.c Thu May 3 21:03:21 2012 (r234984) @@ -147,6 +147,7 @@ timing_loop(struct _a *a) long minres_ns = 20000; int ic, gettimeofday_cycles; int cur_port; + uint64_t n, ns; if (clock_getres(CLOCK_REALTIME, &tmptime) == -1) { perror("clock_getres"); @@ -257,6 +258,13 @@ done: printf("send errors: %ld\n", send_errors); printf("approx send rate: %ld pps\n", (send_calls - send_errors) / a->duration); + n = send_calls - send_errors; + if (n > 0) { + ns = (tmptime.tv_sec - starttime.tv_sec) * 1000000000UL + + (tmptime.tv_nsec - starttime.tv_nsec); + n = ns / n; + } + printf("time/packet: %u ns\n", (u_int)n); printf("approx error rate: %ld\n", (send_errors / send_calls)); printf("waited: %lld\n", waited); printf("approx waits/sec: %lld\n", (long long)(waited / a->duration)); From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:06:55 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6A6641065670; Thu, 3 May 2012 21:06:55 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 7BFF58FC0A; Thu, 3 May 2012 21:06:54 +0000 (UTC) Received: by lbon10 with SMTP id n10so2139926lbo.13 for ; Thu, 03 May 2012 14:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xmQARvYMFE73kil1OfeOehmmBCrKxCLH8Xdq5QNEIGo=; b=OmBGa2simtvDa5oIyjLIdaL3ZZqUUwx1SomiuVg2Y/c+9ehh/BYVy6fINXIE7qwZHL jx5V+dVsKHjaPeo/yKmWe70w64qdXOuaGo5fzbLUriXQ8knX1FHazWFiY7FyBVTWIK7F fihACPCEDI/U7ztxVx3/pQEweBSiWj4kXm+JIuMUyaJ2aT6jD7K8Tccw7jCJTw1SbRIM pEuvwh+1Vf86KA3zWb1CJ8a5IL8GAbp2qJ4UvBgr0qazCQahH4a338hJwhhQ7XGLRlmw KwNto2cEfcE9AvxNvClDM94UMa6fPBPpVo1VnDyehujip6enfcloJfVIGKoMsaDH+KAq 94OA== MIME-Version: 1.0 Received: by 10.152.144.101 with SMTP id sl5mr3414921lab.51.1336079213467; Thu, 03 May 2012 14:06:53 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 14:06:53 -0700 (PDT) In-Reply-To: <20120503132715.GN2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 22:06:53 +0100 X-Google-Sender-Auth: ZqCDjh5acpQSGnh-fxDhNz0oTGA Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:06:55 -0000 2012/5/3 Konstantin Belousov : > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: >> 2012/5/3, Konstantin Belousov : >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> >> 2012/5/3, Konstantin Belousov : >> >> > Author: kib >> >> > Date: Thu May =C2=A03 10:38:02 2012 >> >> > New Revision: 234952 >> >> > URL: http://svn.freebsd.org/changeset/base/234952 >> >> > >> >> > Log: >> >> > =C2=A0 When callout_reset_on() cannot immediately migrate a callout= since it >> >> > =C2=A0 is running on other cpu, the CALLOUT_PENDING flag is tempora= rily >> >> > =C2=A0 cleared. Then, callout_stop() on this, in fact active, callo= ut fails >> >> > =C2=A0 because CALLOUT_PENDING is not set, and callout_stop() retur= ns 0. >> >> > >> >> > =C2=A0 Now, in sleepq_check_timeout(), the failed callout_stop() ca= uses the >> >> > =C2=A0 sleepq code to execute mi_switch() without even setting the = wmesg, >> >> > =C2=A0 since the switch-out is supposed to be transient. In fact, t= he thread >> >> > =C2=A0 is put off the CPU for full timeout interval, instead of bei= ng put on >> >> > =C2=A0 runq immediately. =C2=A0Until timeout fires, the process is = unkillable for >> >> > =C2=A0 obvious reasons. >> >> > >> >> > =C2=A0 Fix this by marking the migrating callouts with CALLOUT_DFRM= IGRATION >> >> > =C2=A0 flag. The flag is cleared by callout_stop_safe() when the fu= nction >> >> > =C2=A0 detects a migration, besides returning the success. The soft= clock() >> >> > =C2=A0 rechecks the flag for migrating callout and cancels its exec= ution if >> >> > =C2=A0 the flag was cleared meantime. >> >> >> >> Can you please clarify why you cannot simply drop the deferred >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? >> > >> > I probably can, I think I went with the route of committed patch >> > because it is slightly less work. Also, the comment in the while() >> > loop suggested me to rely on softclock. >> >> I don't think this is more work at all, the attached patch >> (pre-r234952, untested) should address it properly in few than 10 >> lines: >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >> >> without the need to add further flags and re-using existing mechanisms. > > (cc->cc_curr !=3D c) is not the case which caused the issue. It might be > needed to treatened this way, but the reported case is opposite. Yes, of course, because the migration handover happens in the same critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix is really right. It seems to me that in the case you describe callout_stop() must return 0 and the migration must not be cancelled because the callout is not stopped. It is not stopped not because of the deferred migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid situation to me. Probabilly the bug is in the sleepq use of this mechanism? Attilio --=20 Peace can only be achieved by understanding - A. Einstein From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:15:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2197F106566C; Thu, 3 May 2012 21:15:48 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E77F58FC12; Thu, 3 May 2012 21:15:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43LFlWT063518; Thu, 3 May 2012 21:15:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LFloi063516; Thu, 3 May 2012 21:15:47 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205032115.q43LFloi063516@svn.freebsd.org> From: Josh Paetzel Date: Thu, 3 May 2012 21:15:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234985 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:15:48 -0000 Author: jpaetzel Date: Thu May 3 21:15:47 2012 New Revision: 234985 URL: http://svn.freebsd.org/changeset/base/234985 Log: Fix parsing values which contain multiple "=" signs. Submitted by: glarkin MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Thu May 3 21:03:21 2012 (r234984) +++ head/usr.sbin/pc-sysinstall/backend/functions-parse.sh Thu May 3 21:15:47 2012 (r234985) @@ -33,7 +33,7 @@ get_value_from_string() { if [ -n "${1}" ] then - export VAL="`echo ${1} | cut -d '=' -f 2-15`" + export VAL="`echo ${1} | cut -d '=' -f 2-`" else echo "Error: Did we forgot to supply a string to parse?" exit 1 @@ -45,7 +45,7 @@ get_value_from_cfg_with_spaces() { if [ -n "${1}" ] then - export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-15` + export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-` else exit_err "Error: Did we forgot to supply a setting to grab?" fi @@ -57,7 +57,7 @@ get_value_from_cfg() { if [ -n "${1}" ] then - export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-15 | tr -d ' '` + export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` else exit_err "Error: Did we forgot to supply a setting to grab?" fi @@ -71,7 +71,7 @@ if_check_value_exists() then # Get the first occurrence of the setting from the config, strip out whitespace - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` if [ -z "${VAL}" ] then # This value doesn't exist, lets return @@ -104,7 +104,7 @@ check_value() if [ -n "${1}" -a -n "${2}" ] then # Get the first occurrence of the setting from the config, strip out whitespace - VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` VALID="1" for i in ${2} do @@ -133,7 +133,7 @@ file_sanity_check() grep -q "^${i}=" $CFGF 2>/dev/null if [ $? -eq 0 ] then - LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2- | tr -d ' '` if [ -z "${LN}" ] then echo "Error: Config fails sanity test! ${i}= is empty" From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:16:54 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 914F51065673; Thu, 3 May 2012 21:16:54 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7CC198FC16; Thu, 3 May 2012 21:16:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43LGsPI063595; Thu, 3 May 2012 21:16:54 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LGsYs063593; Thu, 3 May 2012 21:16:54 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205032116.q43LGsYs063593@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 3 May 2012 21:16:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234986 - head/sys/dev/netmap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:16:54 -0000 Author: luigi Date: Thu May 3 21:16:53 2012 New Revision: 234986 URL: http://svn.freebsd.org/changeset/base/234986 Log: print 'netmap stack ring full' only in verbose mode. Modified: head/sys/dev/netmap/netmap.c Modified: head/sys/dev/netmap/netmap.c ============================================================================== --- head/sys/dev/netmap/netmap.c Thu May 3 21:15:47 2012 (r234985) +++ head/sys/dev/netmap/netmap.c Thu May 3 21:16:53 2012 (r234986) @@ -1067,7 +1067,8 @@ netmap_start(struct ifnet *ifp, struct m kring->nr_hwcur + kring->nr_hwavail, len); na->nm_lock(ifp, NETMAP_CORE_LOCK, 0); if (kring->nr_hwavail >= lim) { - D("stack ring %s full\n", ifp->if_xname); + if (netmap_verbose) + D("stack ring %s full\n", ifp->if_xname); goto done; /* no space */ } if (len > NETMAP_BUF_SIZE) { From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:21:46 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F359F1065674; Thu, 3 May 2012 21:21:45 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE9B58FC12; Thu, 3 May 2012 21:21:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43LLj51063809; Thu, 3 May 2012 21:21:45 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LLj9C063807; Thu, 3 May 2012 21:21:45 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205032121.q43LLj9C063807@svn.freebsd.org> From: Josh Paetzel Date: Thu, 3 May 2012 21:21:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234987 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:21:46 -0000 Author: jpaetzel Date: Thu May 3 21:21:45 2012 New Revision: 234987 URL: http://svn.freebsd.org/changeset/base/234987 Log: Add the ability to configure multiple interfaces. Submitted by: glarkin Obtained from: PC-BSD MFC after: 3 days Modified: head/usr.sbin/pc-sysinstall/backend/functions-networking.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-networking.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-networking.sh Thu May 3 21:16:53 2012 (r234986) +++ head/usr.sbin/pc-sysinstall/backend/functions-networking.sh Thu May 3 21:21:45 2012 (r234987) @@ -192,7 +192,7 @@ save_manual_nic() # Get the target nic NIC="$1" - get_value_from_cfg netSaveIP + get_value_from_cfg netSaveIP_${NIC} NETIP="${VAL}" if [ "$NETIP" = "DHCP" ] @@ -212,7 +212,7 @@ save_manual_nic() IFARGS="inet ${NETIP}" # Check if we have a netmask to set - get_value_from_cfg netSaveMask + get_value_from_cfg netSaveMask_${NIC} NETMASK="${VAL}" if [ -n "${NETMASK}" ] then @@ -220,7 +220,7 @@ save_manual_nic() fi fi - get_value_from_cfg netSaveIPv6 + get_value_from_cfg netSaveIPv6_${NIC} NETIP6="${VAL}" if [ -n "${NETIP6}" ] then @@ -239,6 +239,12 @@ save_manual_nic() echo "ifconfig_${NIC}_ipv6=\"${IF6ARGS}\"" >>${FSMNT}/etc/rc.conf fi +}; + +# Function which saves a manual gateway router setup to the installed system +save_manual_router() +{ + # Check if we have a default router to set get_value_from_cfg netSaveDefaultRouter NETROUTE="${VAL}" @@ -253,19 +259,30 @@ save_manual_nic() echo "ipv6_defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf fi +}; + +save_manual_nameserver() +{ # Check if we have a nameserver to enable : > ${FSMNT}/etc/resolv.conf - get_value_from_cfg netSaveNameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf - fi - get_value_from_cfg netSaveIPv6NameServer - NAMESERVER="${VAL}" - if [ -n "${NAMESERVER}" ] - then - echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + get_value_from_cfg_with_spaces netSaveNameServer + NAMESERVERLIST="${VAL}" + if [ ! -z "${NAMESERVERLIST}" ] + then + for NAMESERVER in ${NAMESERVERLIST} + do + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + done + fi + + get_value_from_cfg_with_spaces netSaveIPv6NameServer + NAMESERVERLIST="${VAL}" + if [ ! -z "${NAMESERVERLIST}" ] + then + for NAMESERVER in ${NAMESERVERLIST} + do + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + done fi }; @@ -454,25 +471,30 @@ save_networking_install() { # Check if we have any networking requested to save - get_value_from_cfg netSaveDev + get_value_from_cfg_with_spaces netSaveDev if [ -z "${VAL}" ] then return 0 fi - NETDEV="${VAL}" - if [ "$NETDEV" = "AUTO-DHCP" ] + NETDEVLIST="${VAL}" + if [ "$NETDEVLIST" = "AUTO-DHCP" ] then save_auto_dhcp - elif [ "$NETDEV" = "IPv6-SLAAC" ] + elif [ "$NETDEVLIST" = "IPv6-SLAAC" ] then save_auto_slaac - elif [ "$NETDEV" = "AUTO-DHCP-SLAAC" ] + elif [ "$NETDEVLIST" = "AUTO-DHCP-SLAAC" ] then save_auto_dhcp save_auto_slaac else - save_manual_nic ${NETDEV} + for NETDEV in ${NETDEVLIST} + do + save_manual_nic ${NETDEV} + done + save_manual_router + save_manual_nameserver fi }; From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:28:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E2C3E106564A; Thu, 3 May 2012 21:28:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7C08C8FC08; Thu, 3 May 2012 21:28:42 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q43LSZLq089113; Fri, 4 May 2012 00:28:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q43LSYuf042297; Fri, 4 May 2012 00:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q43LSY9r042296; Fri, 4 May 2012 00:28:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 4 May 2012 00:28:34 +0300 From: Konstantin Belousov To: Attilio Rao Message-ID: <20120503212834.GP2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dKRZzP6oNMY5EfTG" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:28:43 -0000 --dKRZzP6oNMY5EfTG Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: > 2012/5/3 Konstantin Belousov : > > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: > >> 2012/5/3, Konstantin Belousov : > >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: > >> >> 2012/5/3, Konstantin Belousov : > >> >> > Author: kib > >> >> > Date: Thu May =9A3 10:38:02 2012 > >> >> > New Revision: 234952 > >> >> > URL: http://svn.freebsd.org/changeset/base/234952 > >> >> > > >> >> > Log: > >> >> > =9A When callout_reset_on() cannot immediately migrate a callout = since it > >> >> > =9A is running on other cpu, the CALLOUT_PENDING flag is temporar= ily > >> >> > =9A cleared. Then, callout_stop() on this, in fact active, callou= t fails > >> >> > =9A because CALLOUT_PENDING is not set, and callout_stop() return= s 0. > >> >> > > >> >> > =9A Now, in sleepq_check_timeout(), the failed callout_stop() cau= ses the > >> >> > =9A sleepq code to execute mi_switch() without even setting the w= mesg, > >> >> > =9A since the switch-out is supposed to be transient. In fact, th= e thread > >> >> > =9A is put off the CPU for full timeout interval, instead of bein= g put on > >> >> > =9A runq immediately. =9AUntil timeout fires, the process is unki= llable for > >> >> > =9A obvious reasons. > >> >> > > >> >> > =9A Fix this by marking the migrating callouts with CALLOUT_DFRMI= GRATION > >> >> > =9A flag. The flag is cleared by callout_stop_safe() when the fun= ction > >> >> > =9A detects a migration, besides returning the success. The softc= lock() > >> >> > =9A rechecks the flag for migrating callout and cancels its execu= tion if > >> >> > =9A the flag was cleared meantime. > >> >> > >> >> Can you please clarify why you cannot simply drop the deferred > >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? > >> > > >> > I probably can, I think I went with the route of committed patch > >> > because it is slightly less work. Also, the comment in the while() > >> > loop suggested me to rely on softclock. > >> > >> I don't think this is more work at all, the attached patch > >> (pre-r234952, untested) should address it properly in few than 10 > >> lines: > >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch > >> > >> without the need to add further flags and re-using existing mechanisms. > > > > (cc->cc_curr !=3D c) is not the case which caused the issue. It might be > > needed to treatened this way, but the reported case is opposite. >=20 > Yes, of course, because the migration handover happens in the same > critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix is > really right. >=20 > It seems to me that in the case you describe callout_stop() must > return 0 and the migration must not be cancelled because the callout > is not stopped. It is not stopped not because of the deferred > migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid > situation to me. Yes, and my patch makes the callout to be indeed stopped right after migration is finished. Did you looked at the patch itself ? What is the valid situation ? callout_stop returning 0 but not stopping a pending callout ? I have to disagree. >=20 > Probabilly the bug is in the sleepq use of this mechanism? And, what the bug is, then ? --dKRZzP6oNMY5EfTG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+i+IIACgkQC3+MBN1Mb4g8gACdFRb4hFMRIYccDzPtofqjJk2F oFIAoKunxB+SHTkWgKRHleB37GPxYgE0 =iAP5 -----END PGP SIGNATURE----- --dKRZzP6oNMY5EfTG-- From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:31:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D21E8106566B; Thu, 3 May 2012 21:31:50 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id D231C8FC14; Thu, 3 May 2012 21:31:49 +0000 (UTC) Received: by lagv3 with SMTP id v3so2166477lag.13 for ; Thu, 03 May 2012 14:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=emo8DhR5jaLJrOmpkKGNH0Y2TY78tgpKafzBsigjwFU=; b=OWjLZrqhBthWnltUCQq/yOSH4h7seddkE7qwhBxTZwgldSo+7Q7ato+AmXOd+rceLr oYGIlE98yWfv2Y9eiGJAavkJDVzrR+oybarbWn8prxIwKvY6TYiAV0AXOSphvzzPR4hY wrMd9yzvYCp0Dz3nfKMpqhW7yPa9ob8t2lxB0txlRNVr10UxSFN2Q/nJWHKecchNBdbr ZzduoES7WDu0Ohb/40T7XlLZO17wUou47CKCwJcPGL5zxvMIF9r/gT+dTWqk3/XWUEqw P7SUIqG/Uc1qOt3x/92SFPXHXvSbVe1XIT/NiORX60b+7EurGNofmbMo1bbFtrT+5LZZ mgEg== MIME-Version: 1.0 Received: by 10.152.132.166 with SMTP id ov6mr3801938lab.35.1336080708695; Thu, 03 May 2012 14:31:48 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 14:31:48 -0700 (PDT) In-Reply-To: <20120503212834.GP2358@deviant.kiev.zoral.com.ua> References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> <20120503212834.GP2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 22:31:48 +0100 X-Google-Sender-Auth: TH52gjxYDjpMyh00j1TxztT-UIU Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:31:50 -0000 2012/5/3 Konstantin Belousov : > On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: >> 2012/5/3 Konstantin Belousov : >> > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: >> >> 2012/5/3, Konstantin Belousov : >> >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >> >> >> 2012/5/3, Konstantin Belousov : >> >> >> > Author: kib >> >> >> > Date: Thu May =C2=A03 10:38:02 2012 >> >> >> > New Revision: 234952 >> >> >> > URL: http://svn.freebsd.org/changeset/base/234952 >> >> >> > >> >> >> > Log: >> >> >> > =C2=A0 When callout_reset_on() cannot immediately migrate a call= out since it >> >> >> > =C2=A0 is running on other cpu, the CALLOUT_PENDING flag is temp= orarily >> >> >> > =C2=A0 cleared. Then, callout_stop() on this, in fact active, ca= llout fails >> >> >> > =C2=A0 because CALLOUT_PENDING is not set, and callout_stop() re= turns 0. >> >> >> > >> >> >> > =C2=A0 Now, in sleepq_check_timeout(), the failed callout_stop()= causes the >> >> >> > =C2=A0 sleepq code to execute mi_switch() without even setting t= he wmesg, >> >> >> > =C2=A0 since the switch-out is supposed to be transient. In fact= , the thread >> >> >> > =C2=A0 is put off the CPU for full timeout interval, instead of = being put on >> >> >> > =C2=A0 runq immediately. =C2=A0Until timeout fires, the process = is unkillable for >> >> >> > =C2=A0 obvious reasons. >> >> >> > >> >> >> > =C2=A0 Fix this by marking the migrating callouts with CALLOUT_D= FRMIGRATION >> >> >> > =C2=A0 flag. The flag is cleared by callout_stop_safe() when the= function >> >> >> > =C2=A0 detects a migration, besides returning the success. The s= oftclock() >> >> >> > =C2=A0 rechecks the flag for migrating callout and cancels its e= xecution if >> >> >> > =C2=A0 the flag was cleared meantime. >> >> >> >> >> >> Can you please clarify why you cannot simply drop the deferred >> >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? >> >> > >> >> > I probably can, I think I went with the route of committed patch >> >> > because it is slightly less work. Also, the comment in the while() >> >> > loop suggested me to rely on softclock. >> >> >> >> I don't think this is more work at all, the attached patch >> >> (pre-r234952, untested) should address it properly in few than 10 >> >> lines: >> >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >> >> >> >> without the need to add further flags and re-using existing mechanism= s. >> > >> > (cc->cc_curr !=3D c) is not the case which caused the issue. It might = be >> > needed to treatened this way, but the reported case is opposite. >> >> Yes, of course, because the migration handover happens in the same >> critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix i= s >> really right. >> >> It seems to me that in the case you describe callout_stop() must >> return 0 and the migration must not be cancelled because the callout >> is not stopped. It is not stopped not because of the deferred >> migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid >> situation to me. > Yes, and my patch makes the callout to be indeed stopped right after > migration is finished. Did you looked at the patch itself ? > > What is the valid situation ? callout_stop returning 0 but not stopping > a pending callout ? I have to disagree. The function callout_stop() cancels a callout if it is currently pending. If the callout is pending, then callout_stop() will return a non-zero value. If the callout is not set, has already been serviced or is cur= =E2=80=90 rently being serviced, then zero will be returned. If the callout has= an associated mutex, then that mutex must be held when this function is called. [ From the callout manpage ] If the "callout is currently being serviced" means cc->cc_curr =3D=3D c and it must return 0. I still fail in seeing what are you trying to fix here. Attilio --=20 Peace can only be achieved by understanding - A. Einstein From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:39:24 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 089A0106564A; Thu, 3 May 2012 21:39:24 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E7BE78FC0A; Thu, 3 May 2012 21:39:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43LdNXa064491; Thu, 3 May 2012 21:39:23 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LdNGa064486; Thu, 3 May 2012 21:39:23 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201205032139.q43LdNGa064486@svn.freebsd.org> From: Jamie Gritton Date: Thu, 3 May 2012 21:39:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234988 - head/usr.sbin/jail X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:39:24 -0000 Author: jamie Date: Thu May 3 21:39:23 2012 New Revision: 234988 URL: http://svn.freebsd.org/changeset/base/234988 Log: Add a meta-parameter IP__NULL to enum intparam, instead of mixing enum values and zeroes. This keeps clang happy (and is just good form). Submitted by: dim Modified: head/usr.sbin/jail/command.c head/usr.sbin/jail/config.c head/usr.sbin/jail/jail.c head/usr.sbin/jail/jailp.h Modified: head/usr.sbin/jail/command.c ============================================================================== --- head/usr.sbin/jail/command.c Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/command.c Thu May 3 21:39:23 2012 (r234988) @@ -100,7 +100,7 @@ next_command(struct cfjail *j) if (j->comstring == NULL) { j->comparam += create_failed ? -1 : 1; switch ((comparam = *j->comparam)) { - case 0: + case IP__NULL: return 0; case IP_MOUNT_DEVFS: if (!bool_param(j->intparams[IP_MOUNT_DEVFS])) Modified: head/usr.sbin/jail/config.c ============================================================================== --- head/usr.sbin/jail/config.c Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/config.c Thu May 3 21:39:23 2012 (r234988) @@ -328,7 +328,7 @@ add_param(struct cfjail *j, const struct } } else { flags = PF_APPEND; - if (ipnum != 0) { + if (ipnum != IP__NULL) { name = intparams[ipnum].name; flags |= intparams[ipnum].flags; } else if ((cs = strchr(value, '='))) { @@ -350,7 +350,7 @@ add_param(struct cfjail *j, const struct } /* See if this parameter has already been added. */ - if (ipnum != 0) + if (ipnum != IP__NULL) dp = j->intparams[ipnum]; else TAILQ_FOREACH(dp, &j->params, tq) @@ -375,10 +375,10 @@ add_param(struct cfjail *j, const struct np->flags = flags; np->gen = 0; TAILQ_INSERT_TAIL(&j->params, np, tq); - if (ipnum != 0) + if (ipnum != IP__NULL) j->intparams[ipnum] = np; else - for (ipnum = 1; ipnum < IP_NPARAM; ipnum++) + for (ipnum = IP__NULL + 1; ipnum < IP_NPARAM; ipnum++) if (!(intparams[ipnum].flags & PF_CONV) && equalopts(name, intparams[ipnum].name)) { j->intparams[ipnum] = np; Modified: head/usr.sbin/jail/jail.c ============================================================================== --- head/usr.sbin/jail/jail.c Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/jail.c Thu May 3 21:39:23 2012 (r234988) @@ -81,7 +81,7 @@ static struct permspec perm_sysctl[] = { }; static const enum intparam startcommands[] = { - 0, + IP__NULL, #ifdef INET IP__IP4_IFADDR, #endif @@ -97,11 +97,11 @@ static const enum intparam startcommands IP_EXEC_START, IP_COMMAND, IP_EXEC_POSTSTART, - 0 + IP__NULL }; static const enum intparam stopcommands[] = { - 0, + IP__NULL, IP_EXEC_PRESTOP, IP_EXEC_STOP, IP_STOP_TIMEOUT, @@ -116,7 +116,7 @@ static const enum intparam stopcommands[ #ifdef INET IP__IP4_IFADDR, #endif - 0 + IP__NULL }; int Modified: head/usr.sbin/jail/jailp.h ============================================================================== --- head/usr.sbin/jail/jailp.h Thu May 3 21:21:45 2012 (r234987) +++ head/usr.sbin/jail/jailp.h Thu May 3 21:39:23 2012 (r234988) @@ -71,7 +71,8 @@ #define JF_DO_STOP(js) (((js) & (JF_SET | JF_STOP)) == JF_STOP) enum intparam { - IP_ALLOW_DYING = 1, /* Allow making changes to a dying jail */ + IP__NULL = 0, /* Null command */ + IP_ALLOW_DYING, /* Allow making changes to a dying jail */ IP_COMMAND, /* Command run inside jail at creation */ IP_DEPEND, /* Jail starts after (stops before) another */ IP_EXEC_CLEAN, /* Run commands in a clean environment */ From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:44:02 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C00321065673; Thu, 3 May 2012 21:44:02 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 918268FC0C; Thu, 3 May 2012 21:44:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43Li2HR064711; Thu, 3 May 2012 21:44:02 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43Li2og064707; Thu, 3 May 2012 21:44:02 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201205032144.q43Li2og064707@svn.freebsd.org> From: Attilio Rao Date: Thu, 3 May 2012 21:44:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234989 - in head/sys: amd64/include i386/include x86/x86 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:44:02 -0000 Author: attilio Date: Thu May 3 21:44:01 2012 New Revision: 234989 URL: http://svn.freebsd.org/changeset/base/234989 Log: Revert part of r234723 by re-enabling the SMP protection for intr_bind() on x86. This has been requested by jhb and I strongly disagree with this, but as long as he is the x86 and interrupt subsystem maintainer I will follow his directives. The disagreement cames from what we should really consider as a public KPI. IMHO, if we really need a selection between the kernel functions, we may need an explicit protection like _KERNEL_KPI, which defines which subset of the kernel function might really be considered as part of the KPI (for thirdy part modules) and which not. As long as we don't have this mechanism I just consider any possible function as usable by thirdy part code, thus intr_bind() included. MFC after: 1 week Modified: head/sys/amd64/include/intr_machdep.h head/sys/i386/include/intr_machdep.h head/sys/x86/x86/intr_machdep.c Modified: head/sys/amd64/include/intr_machdep.h ============================================================================== --- head/sys/amd64/include/intr_machdep.h Thu May 3 21:39:23 2012 (r234988) +++ head/sys/amd64/include/intr_machdep.h Thu May 3 21:44:01 2012 (r234989) @@ -144,7 +144,9 @@ void intr_add_cpu(u_int cpu); int intr_add_handler(const char *name, int vector, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep); +#ifdef SMP int intr_bind(u_int vector, u_char cpu); +#endif int intr_config_intr(int vector, enum intr_trigger trig, enum intr_polarity pol); int intr_describe(u_int vector, void *ih, const char *descr); Modified: head/sys/i386/include/intr_machdep.h ============================================================================== --- head/sys/i386/include/intr_machdep.h Thu May 3 21:39:23 2012 (r234988) +++ head/sys/i386/include/intr_machdep.h Thu May 3 21:44:01 2012 (r234989) @@ -134,7 +134,9 @@ void elcr_write_trigger(u_int irq, enum void intr_add_cpu(u_int cpu); int intr_add_handler(const char *name, int vector, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep); +#ifdef SMP int intr_bind(u_int vector, u_char cpu); +#endif int intr_config_intr(int vector, enum intr_trigger trig, enum intr_polarity pol); int intr_describe(u_int vector, void *ih, const char *descr); Modified: head/sys/x86/x86/intr_machdep.c ============================================================================== --- head/sys/x86/x86/intr_machdep.c Thu May 3 21:39:23 2012 (r234988) +++ head/sys/x86/x86/intr_machdep.c Thu May 3 21:44:01 2012 (r234989) @@ -566,14 +566,6 @@ intr_next_cpu(void) return (PCPU_GET(apic_id)); } -/* Return EOPNOTSUPP in the UP case. */ -int -intr_bind(u_int vector __unused, u_char cpu __unused) -{ - - return (EOPNOTSUPP); -} - /* Use an empty stub for compatibility. */ void intr_add_cpu(u_int cpu __unused) From owner-svn-src-head@FreeBSD.ORG Thu May 3 21:53:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 92E29106564A; Thu, 3 May 2012 21:53:26 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D28E8FC08; Thu, 3 May 2012 21:53:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q43LrQt8065162; Thu, 3 May 2012 21:53:26 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q43LrQCL065159; Thu, 3 May 2012 21:53:26 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205032153.q43LrQCL065159@svn.freebsd.org> From: Josh Paetzel Date: Thu, 3 May 2012 21:53:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234990 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 21:53:26 -0000 Author: jpaetzel Date: Thu May 3 21:53:25 2012 New Revision: 234990 URL: http://svn.freebsd.org/changeset/base/234990 Log: Fix some issues creating zpool mirror / raidz1(2)(3) devices. Fix issues stamping boot on other ZFS drives, now you can boot after removing mirror drive. Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Thu May 3 21:44:01 2012 (r234989) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Thu May 3 21:53:25 2012 (r234990) @@ -50,41 +50,39 @@ get_fs_line_xvars() ACTIVEDEV="${1}" LINE="${2}" - echo $LINE | cut -d ' ' -f 4 | grep -q ' (' 2>/dev/null + echo $LINE | cut -d ' ' -f 4 | grep -q '(' 2>/dev/null + if [ $? -ne 0 ] ; then return ; fi + + # See if we are looking for ZFS specific options + echo $LINE | grep -q '^ZFS' 2>/dev/null if [ $? -eq 0 ] ; then + ZTYPE="NONE" + ZFSVARS="`echo $LINE | cut -d ' ' -f 4-20 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - # See if we are looking for ZFS specific options - echo $LINE | grep -q '^ZFS' 2>/dev/null + echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null if [ $? -eq 0 ] ; then - ZTYPE="NONE" - ZFSVARS="`echo $LINE | cut -d ' ' -f 4 |cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - - echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null - if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` - fi - - # Return the ZFS options - if [ "${ZTYPE}" = "NONE" ] ; then - VAR="${ACTIVEDEV} ${ZFSVARS}" - else - VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" - fi - export VAR - return - fi # End of ZFS block + fi - # See if we are looking for UFS specific newfs options - echo $LINE | grep -q '^UFS' 2>/dev/null - if [ $? -eq 0 ] ; then - FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" - VAR="${FSVARS}" - export VAR - return + # Return the ZFS options + if [ "${ZTYPE}" = "NONE" ] ; then + VAR="${ACTIVEDEV} ${ZFSVARS}" + else + VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" fi + export VAR + return + fi # End of ZFS block - fi # End of xtra-options block + # See if we are looking for UFS specific newfs options + echo $LINE | grep -q '^UFS' 2>/dev/null + if [ $? -eq 0 ] ; then + FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" + VAR="${FSVARS}" + export VAR + return + fi # If we got here, set VAR to empty and export export VAR="" @@ -96,8 +94,10 @@ setup_zfs_mirror_parts() { _nZFS="" + ZTYPE="`echo ${1} | awk '{print $1}'`" + # Using mirroring, setup boot partitions on each disk - _mirrline="`echo ${1} | sed 's|mirror ||g'`" + _mirrline="`echo ${1} | sed 's|mirror ||g' | sed 's|raidz1 ||g' | sed 's|raidz2 ||g' | sed 's|raidz3 ||g' | sed 's|raidz ||g'`" for _zvars in $_mirrline do echo "Looping through _zvars: $_zvars" >>${LOGOUT} @@ -107,15 +107,16 @@ setup_zfs_mirror_parts() is_disk "$_zvars" >/dev/null 2>/dev/null if [ $? -eq 0 ] ; then - echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} + echo "Setting up ZFS disk $_zvars" >>${LOGOUT} init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null - rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null + rc_halt "gpart add -a 4k -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null + rc_halt "gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null _nZFS="$_nZFS ${_zvars}p2" else _nZFS="$_nZFS ${_zvars}" fi done - echo "mirror $2 `echo $_nZFS | tr -s ' '`" + echo "$ZTYPE $2 `echo $_nZFS | tr -s ' '`" } ; # Function which creates a unique label name for the specified mount @@ -290,15 +291,15 @@ setup_gpart_partitions() else get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" fi - XTRAOPTS="${VAR}" + XTRAOPTS="$VAR" # Check if using zfs mirror - echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null + echo ${XTRAOPTS} | grep -q -e "mirror" -e "raidz" if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else - XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}") + XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}") fi fi Modified: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Thu May 3 21:44:01 2012 (r234989) +++ head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh Thu May 3 21:53:25 2012 (r234990) @@ -44,6 +44,23 @@ setup_zfs_filesystem() sleep 5 sync + # Check if we have multiple zfs mounts specified + for i in `echo ${PARTMNT} | sed 's|,| |g'` + do + # Check if we ended up with needing a zfs bootable partition + if [ "${i}" = "/" -o "${i}" = "/boot" ] + then + if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi + if [ "${PARTGEOM}" = "MBR" ] ; then + # Lets stamp the proper ZFS boot loader + echo_log "Setting up ZFS boot loader support" + rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" + rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" + fi + fi + done + + # Check if we have some custom zpool arguments and use them if so if [ ! -z "${ZPOOLOPTS}" ] ; then rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}" @@ -55,23 +72,13 @@ setup_zfs_filesystem() # Disable atime for this zfs partition, speed increase rc_nohalt "zfs set atime=off ${ZPOOLNAME}" - # Check if we have multiple zfs mounts specified + # Check if we need to set a bootable zpool for i in `echo ${PARTMNT} | sed 's|,| |g'` do - # Check if we ended up with needing a zfs bootable partition - if [ "${i}" = "/" -o "${i}" = "/boot" ] - then + if [ "${i}" = "/" -o "${i}" = "/boot" ] ; then if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi - if [ "${PARTGEOM}" = "MBR" ] - then - # Lets stamp the proper ZFS boot loader - echo_log "Setting up ZFS boot loader support" - rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" - rc_halt "zpool export ${ZPOOLNAME}" - rc_halt "dd if=/boot/zfsboot of=${ROOTSLICE} count=1" - rc_halt "dd if=/boot/zfsboot of=${PART}${EXT} skip=1 seek=1024" - rc_halt "zpool import ${ZPOOLNAME}" - fi + echo_log "Stamping zpool as bootfs" + rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" fi done @@ -90,11 +97,6 @@ setup_filesystems() for PART in `ls ${PARTDIR}` do PARTDEV="`echo $PART | sed 's|-|/|g'`" - if [ ! -e "${PARTDEV}" ] - then - exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" - fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`" @@ -103,6 +105,10 @@ setup_filesystems() PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 6`" PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d '#' -f 7`" + if [ ! -e "${PARTDEV}" ] ; then + exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?" + fi + # Make sure journaling isn't enabled on this device if [ -e "${PARTDEV}.journal" ] then From owner-svn-src-head@FreeBSD.ORG Thu May 3 22:24:26 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 772C6106564A; Thu, 3 May 2012 22:24:26 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id 84D848FC14; Thu, 3 May 2012 22:24:25 +0000 (UTC) Received: by lbon10 with SMTP id n10so2195187lbo.13 for ; Thu, 03 May 2012 15:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Ll9aLERW+fYxBAo7n3vXDfzhaye9ydx8Nb6rB0hMh9s=; b=bXL65MQguDkolXotkLAgkli/g4tsmC6F/nCqttppRE74e0ljo7Rmu9T566rm2/lNsu WrWQGBXX85aUf/8Vnxxj9EzGIU/kRUT0rDU+aokYfwYGIEqVG3JAGqRvjzmWhRYqU1Ec 1JAI4dup7ePWKdMbvKSROEvX9QEGCXex9K93N4d/81gtA0zS9tPCw5GXPC+7bV2fYgDD nq7+hV1ukRFiQjGqe3dNVshLiHwmKdHzg67CK0RN2oqOMNM1Wu3FGPuOFZCwmybXA8Pf MJa3c34jWp4wCFTcAhMFTm78P1LvyssRQUHxFt3LgMERlU+aBwTVl/sUcldQt1i6W7xQ AfRg== MIME-Version: 1.0 Received: by 10.112.37.132 with SMTP id y4mr1857393lbj.8.1336083864102; Thu, 03 May 2012 15:24:24 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.27.65 with HTTP; Thu, 3 May 2012 15:24:23 -0700 (PDT) In-Reply-To: References: <201205031038.q43Ac2eZ032779@svn.freebsd.org> <20120503114913.GJ2358@deviant.kiev.zoral.com.ua> <20120503132715.GN2358@deviant.kiev.zoral.com.ua> <20120503212834.GP2358@deviant.kiev.zoral.com.ua> Date: Thu, 3 May 2012 23:24:23 +0100 X-Google-Sender-Auth: P3Ax9-DfnhXpngnoCSfSm4I0tVM Message-ID: From: Attilio Rao To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, christian.esken@trivago.com Subject: Re: svn commit: r234952 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2012 22:24:26 -0000 2012/5/3 Attilio Rao : > 2012/5/3 Konstantin Belousov : >> On Thu, May 03, 2012 at 10:06:53PM +0100, Attilio Rao wrote: >>> 2012/5/3 Konstantin Belousov : >>> > On Thu, May 03, 2012 at 02:14:20PM +0100, Attilio Rao wrote: >>> >> 2012/5/3, Konstantin Belousov : >>> >> > On Thu, May 03, 2012 at 12:02:08PM +0100, Attilio Rao wrote: >>> >> >> 2012/5/3, Konstantin Belousov : >>> >> >> > Author: kib >>> >> >> > Date: Thu May =C2=A03 10:38:02 2012 >>> >> >> > New Revision: 234952 >>> >> >> > URL: http://svn.freebsd.org/changeset/base/234952 >>> >> >> > >>> >> >> > Log: >>> >> >> > =C2=A0 When callout_reset_on() cannot immediately migrate a cal= lout since it >>> >> >> > =C2=A0 is running on other cpu, the CALLOUT_PENDING flag is tem= porarily >>> >> >> > =C2=A0 cleared. Then, callout_stop() on this, in fact active, c= allout fails >>> >> >> > =C2=A0 because CALLOUT_PENDING is not set, and callout_stop() r= eturns 0. >>> >> >> > >>> >> >> > =C2=A0 Now, in sleepq_check_timeout(), the failed callout_stop(= ) causes the >>> >> >> > =C2=A0 sleepq code to execute mi_switch() without even setting = the wmesg, >>> >> >> > =C2=A0 since the switch-out is supposed to be transient. In fac= t, the thread >>> >> >> > =C2=A0 is put off the CPU for full timeout interval, instead of= being put on >>> >> >> > =C2=A0 runq immediately. =C2=A0Until timeout fires, the process= is unkillable for >>> >> >> > =C2=A0 obvious reasons. >>> >> >> > >>> >> >> > =C2=A0 Fix this by marking the migrating callouts with CALLOUT_= DFRMIGRATION >>> >> >> > =C2=A0 flag. The flag is cleared by callout_stop_safe() when th= e function >>> >> >> > =C2=A0 detects a migration, besides returning the success. The = softclock() >>> >> >> > =C2=A0 rechecks the flag for migrating callout and cancels its = execution if >>> >> >> > =C2=A0 the flag was cleared meantime. >>> >> >> >>> >> >> Can you please clarify why you cannot simply drop the deferred >>> >> >> migration in the case !CALLOUT_PENDING in callout_stop_safe()? >>> >> > >>> >> > I probably can, I think I went with the route of committed patch >>> >> > because it is slightly less work. Also, the comment in the while() >>> >> > loop suggested me to rely on softclock. >>> >> >>> >> I don't think this is more work at all, the attached patch >>> >> (pre-r234952, untested) should address it properly in few than 10 >>> >> lines: >>> >> http://www.freebsd.org/~attilio/callout_cancel_mig_stop.patch >>> >> >>> >> without the need to add further flags and re-using existing mechanis= ms. >>> > >>> > (cc->cc_curr !=3D c) is not the case which caused the issue. It might= be >>> > needed to treatened this way, but the reported case is opposite. >>> >>> Yes, of course, because the migration handover happens in the same >>> critical context of cc->cc_curr =3D=3D c, but now I wonder if this fix = is >>> really right. >>> >>> It seems to me that in the case you describe callout_stop() must >>> return 0 and the migration must not be cancelled because the callout >>> is not stopped. It is not stopped not because of the deferred >>> migration but because cc->cc_curr =3D=3D c. It seems a perfectly valid >>> situation to me. >> Yes, and my patch makes the callout to be indeed stopped right after >> migration is finished. Did you looked at the patch itself ? >> >> What is the valid situation ? callout_stop returning 0 but not stopping >> a pending callout ? I have to disagree. > > The function callout_stop() cancels a callout if it is currently pending. > =C2=A0 =C2=A0 If the callout is pending, then callout_stop() will return = a non-zero > =C2=A0 =C2=A0 value. =C2=A0If the callout is not set, has already been se= rviced or is cur=E2=80=90 > =C2=A0 =C2=A0 rently being serviced, then zero will be returned. =C2=A0If= the callout has an > =C2=A0 =C2=A0 associated mutex, then that mutex must be held when this fu= nction is > =C2=A0 =C2=A0 called. > > [ From the callout manpage ] > > If the "callout is currently being serviced" means cc->cc_curr =3D=3D c > and it must return 0. Elaborating some more, I see a discrepancy here in the callout interface, which is also present pre-your patch and pre-migration delay. Basically, immagine a callout rearmed during its callback (pretty typical) and a callout_stop() running just after the callout has been rearmed and it is *still* in the callback. What we find is that CALLOUT_PENDING is on and that cc_curr =3D=3D cc. I don't think that the callout should stop successfully in this case. However, because of how _callout_stop_safe() is written, CALLOUT_PENDING check has precedence and wins, returning 1 and removing the CALLOUT_PENDING flag, but please note that the callback is still running (even if only for little time). I think this generally works ok because most of the callout callbacks rearm the callout as last thing in their operation. But I think this is highly fragile and we cannot really rely on this feature. You are seeing a problem in the deferred migration case because it does the other way around, it prefers the check over cc_curr =3D=3D cc to the "pending" (callout migration in this case). I think this is only a problem, also, with callouts which don't have a lock associated with them, like the sleepqueue case, because otherwise the interlock would leave the state consistent. I think we need to think carefully about a pattern for this case that deals with all the races, I need to give this more thinking, but definitively it seems to me we need a patch at the callout policy level. Attilio --=20 Peace can only be achieved by understanding - A. Einstein From owner-svn-src-head@FreeBSD.ORG Fri May 4 02:26:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2494E106564A; Fri, 4 May 2012 02:26:16 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0FE718FC08; Fri, 4 May 2012 02:26:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q442QF8X081454; Fri, 4 May 2012 02:26:15 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q442QFfp081451; Fri, 4 May 2012 02:26:15 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205040226.q442QFfp081451@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 May 2012 02:26:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234992 - head/sys/mips/atheros X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 02:26:16 -0000 Author: adrian Date: Fri May 4 02:26:15 2012 New Revision: 234992 URL: http://svn.freebsd.org/changeset/base/234992 Log: Disable setting the MII port speed. This seems to break at least my test board here (AR71xx + AR8316 switch PHY). Since I do have a whole sleuth of "normal" PHY boards (with an AR71xx on a normal PHY port), I'll do some further testing with those to determine whether this is a general issue, or whether it's limited to the behaviour of the "fake" dedicated PHY port mode on these atheros switches. Modified: head/sys/mips/atheros/if_arge.c Modified: head/sys/mips/atheros/if_arge.c ============================================================================== --- head/sys/mips/atheros/if_arge.c Fri May 4 01:35:13 2012 (r234991) +++ head/sys/mips/atheros/if_arge.c Fri May 4 02:26:15 2012 (r234992) @@ -932,7 +932,19 @@ arge_set_pll(struct arge_softc *sc, int ar71xx_device_set_pll_ge(sc->arge_mac_unit, if_speed, pll); /* set MII registers */ + /* + * This was introduced to match what the Linux ag71xx ethernet + * driver does. For the AR71xx case, it does set the port + * MII speed. However, if this is done, non-gigabit speeds + * are not at all reliable when speaking via RGMII through + * 'bridge' PHY port that's pretending to be a local PHY. + * + * Until that gets root caused, and until an AR71xx + normal + * PHY board is tested, leave this disabled. + */ +#if 0 ar71xx_device_set_mii_speed(sc->arge_mac_unit, if_speed); +#endif } From owner-svn-src-head@FreeBSD.ORG Fri May 4 07:32:58 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59D5D106564A; Fri, 4 May 2012 07:32:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 43DD08FC0C; Fri, 4 May 2012 07:32:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q447WwFV092211; Fri, 4 May 2012 07:32:58 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q447Wwcw092207; Fri, 4 May 2012 07:32:58 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205040732.q447Wwcw092207@svn.freebsd.org> From: Alexander Motin Date: Fri, 4 May 2012 07:32:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234993 - in head: sbin/geom/class/raid sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 07:32:58 -0000 Author: mav Date: Fri May 4 07:32:57 2012 New Revision: 234993 URL: http://svn.freebsd.org/changeset/base/234993 Log: Implement read-only support for volumes in optimal state (without using redundancy) for the following RAID levels: RAID4/5E/5EE/6/MDF. Modified: head/sbin/geom/class/raid/graid.8 head/sys/geom/raid/g_raid.c head/sys/geom/raid/tr_raid5.c Modified: head/sbin/geom/class/raid/graid.8 ============================================================================== --- head/sbin/geom/class/raid/graid.8 Fri May 4 02:26:15 2012 (r234992) +++ head/sbin/geom/class/raid/graid.8 Fri May 4 07:32:57 2012 (r234993) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 30, 2012 +.Dd May 3, 2012 .Dt GRAID 8 .Os .Sh NAME @@ -261,9 +261,11 @@ own risk: RAID1 (3+ disks), RAID10 (6+ d .Sh SUPPORTED RAID LEVELS The GEOM RAID class follows a modular design, allowing different RAID levels to be used. -Support for the following RAID levels is currently implemented: RAID0, RAID1, -RAID1E, RAID5, RAID10, SINGLE, CONCAT. -RAID5 support is read-only and only for volumes in optimal state. +Full support for the following RAID levels is currently implemented: +RAID0, RAID1, RAID1E, RAID10, SINGLE, CONCAT. +The following RAID levels supported as read-only for volumes in optimal +state (without using redundancy): RAID4, RAID5, RAID5E, RAID5EE, RAID6, +RAIDMDF. .Sh RAID LEVEL MIGRATION The GEOM RAID class has no support for RAID level migration, allowed by some metadata formats. Modified: head/sys/geom/raid/g_raid.c ============================================================================== --- head/sys/geom/raid/g_raid.c Fri May 4 02:26:15 2012 (r234992) +++ head/sys/geom/raid/g_raid.c Fri May 4 07:32:57 2012 (r234993) @@ -376,17 +376,17 @@ g_raid_volume_str2level(const char *str, else if (strcasecmp(str, "RAID3-P0") == 0) { *level = G_RAID_VOLUME_RL_RAID3; *qual = G_RAID_VOLUME_RLQ_R3P0; - } else if (strcasecmp(str, "RAID3-PN") == 0 && + } else if (strcasecmp(str, "RAID3-PN") == 0 || strcasecmp(str, "RAID3") == 0) { *level = G_RAID_VOLUME_RL_RAID3; - *qual = G_RAID_VOLUME_RLQ_R3P0; + *qual = G_RAID_VOLUME_RLQ_R3PN; } else if (strcasecmp(str, "RAID4-P0") == 0) { *level = G_RAID_VOLUME_RL_RAID4; *qual = G_RAID_VOLUME_RLQ_R4P0; - } else if (strcasecmp(str, "RAID4-PN") == 0 && + } else if (strcasecmp(str, "RAID4-PN") == 0 || strcasecmp(str, "RAID4") == 0) { *level = G_RAID_VOLUME_RL_RAID4; - *qual = G_RAID_VOLUME_RLQ_R4P0; + *qual = G_RAID_VOLUME_RLQ_R4PN; } else if (strcasecmp(str, "RAID5-RA") == 0) { *level = G_RAID_VOLUME_RL_RAID5; *qual = G_RAID_VOLUME_RLQ_R5RA; Modified: head/sys/geom/raid/tr_raid5.c ============================================================================== --- head/sys/geom/raid/tr_raid5.c Fri May 4 02:26:15 2012 (r234992) +++ head/sys/geom/raid/tr_raid5.c Fri May 4 07:32:57 2012 (r234993) @@ -106,9 +106,16 @@ g_raid_tr_taste_raid5(struct g_raid_tr_o trs = (struct g_raid_tr_raid5_object *)tr; qual = tr->tro_volume->v_raid_level_qualifier; - if (tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5 && + if (tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID4 && + qual >= 0 && qual <= 1) { + /* RAID4 */ + } else if ((tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5 || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5E || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID5EE || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAID6 || + tr->tro_volume->v_raid_level == G_RAID_VOLUME_RL_RAIDMDF) && qual >= 0 && qual <= 3) { - /* RAID5 */ + /* RAID5/5E/5EE/6/MDF */ } else return (G_RAID_TR_TASTE_FAIL); trs->trso_starting = 1; @@ -203,30 +210,55 @@ g_raid_tr_iostart_raid5_read(struct g_ra struct bio *cbp; char *addr; off_t offset, start, length, nstripe, remain; - int no, pno; - u_int strip_size, qual; + int no, pno, ddisks, pdisks; + u_int strip_size, lvl, qual; vol = tr->tro_volume; addr = bp->bio_data; strip_size = vol->v_strip_size; + lvl = tr->tro_volume->v_raid_level; qual = tr->tro_volume->v_raid_level_qualifier; /* Stripe number. */ nstripe = bp->bio_offset / strip_size; /* Start position in stripe. */ start = bp->bio_offset % strip_size; + /* Number of data and parity disks. */ + if (lvl == G_RAID_VOLUME_RL_RAIDMDF) + pdisks = 3; + else if (lvl == G_RAID_VOLUME_RL_RAID5EE || + lvl == G_RAID_VOLUME_RL_RAID6) + pdisks = 2; + else + pdisks = 1; + ddisks = vol->v_disks_count - pdisks; /* Parity disk number. */ - pno = nstripe / (vol->v_disks_count - 1) % vol->v_disks_count; - if (qual >= 2) - pno = (vol->v_disks_count - 1) - pno; - /* Disk number. */ - no = nstripe % (vol->v_disks_count - 1); - if (qual & 1) { - no = (pno + no + 1) % vol->v_disks_count; - } else if (no >= pno) - no++; + if (lvl == G_RAID_VOLUME_RL_RAID4) { + if (qual == 0) /* P0 */ + pno = 0; + else /* PN */ + pno = ddisks; + } else { + pno = (nstripe / ddisks) % vol->v_disks_count; + if (qual >= 2) { /* PN/Left */ + pno = ddisks - pno; + if (pno < 0) + pno += vol->v_disks_count; + } + } + /* Data disk number. */ + no = nstripe % ddisks; + if (lvl == G_RAID_VOLUME_RL_RAID4) { + if (qual == 0) + no += pdisks; + } else if (qual & 1) { /* Continuation/Symmetric */ + no = (pno + pdisks + no) % vol->v_disks_count; + } else if (no >= pno) /* Restart/Asymmetric */ + no += pdisks; + else + no += imax(0, pno + pdisks - vol->v_disks_count); /* Stripe start position in disk. */ - offset = (nstripe / (vol->v_disks_count - 1)) * strip_size; + offset = (nstripe / ddisks) * strip_size; /* Length of data to operate. */ remain = bp->bio_length; @@ -242,33 +274,37 @@ g_raid_tr_iostart_raid5_read(struct g_ra cbp->bio_caller1 = &vol->v_subdisks[no]; bioq_insert_tail(&queue, cbp); no++; - if (qual & 1) { + if (lvl == G_RAID_VOLUME_RL_RAID4) { + no %= vol->v_disks_count; + if (no == pno) + no = (no + pdisks) % vol->v_disks_count; + } else if (qual & 1) { /* Continuation/Symmetric */ no %= vol->v_disks_count; if (no == pno) { - if (qual < 2) { - pno = (pno + 1) % vol->v_disks_count; - no = (no + 2) % vol->v_disks_count; - } else if (pno == 0) - pno = vol->v_disks_count - 1; - else - pno--; + if (qual < 2) /* P0/Right */ + pno++; + else /* PN/Left */ + pno += vol->v_disks_count - 1; + pno %= vol->v_disks_count; + no = (pno + pdisks) % vol->v_disks_count; offset += strip_size; } - } else { + } else { /* Restart/Asymmetric */ if (no == pno) - no++; + no += pdisks; if (no >= vol->v_disks_count) { - no %= vol->v_disks_count; - if (qual < 2) - pno = (pno + 1) % vol->v_disks_count; - else if (pno == 0) - pno = vol->v_disks_count - 1; + no -= vol->v_disks_count; + if (qual < 2) /* P0/Right */ + pno++; + else /* PN/Left */ + pno += vol->v_disks_count - 1; + pno %= vol->v_disks_count; + if (no == pno) + no += pdisks; else - pno--; + no += imax(0, pno + pdisks - vol->v_disks_count); offset += strip_size; } - if (no == pno) - no++; } remain -= length; addr += length; From owner-svn-src-head@FreeBSD.ORG Fri May 4 08:59:20 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5D0AC106566B; Fri, 4 May 2012 08:59:20 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 48BC78FC0C; Fri, 4 May 2012 08:59:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q448xKrs094852; Fri, 4 May 2012 08:59:20 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q448xKXm094850; Fri, 4 May 2012 08:59:20 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201205040859.q448xKXm094850@svn.freebsd.org> From: Alexander Motin Date: Fri, 4 May 2012 08:59:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234994 - head/sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 08:59:20 -0000 Author: mav Date: Fri May 4 08:59:19 2012 New Revision: 234994 URL: http://svn.freebsd.org/changeset/base/234994 Log: Fix bug causing memory corruption and panics with big-endian metadata. Modified: head/sys/geom/raid/md_ddf.c Modified: head/sys/geom/raid/md_ddf.c ============================================================================== --- head/sys/geom/raid/md_ddf.c Fri May 4 07:32:57 2012 (r234993) +++ head/sys/geom/raid/md_ddf.c Fri May 4 08:59:19 2012 (r234994) @@ -789,7 +789,7 @@ ddf_meta_update(struct ddf_meta *meta, s if (isff(spde->PD_GUID, 24)) continue; j = ddf_meta_find_pd(meta, NULL, - src->pdr->entry[i].PD_Reference); + GET32(src, pdr->entry[i].PD_Reference)); if (j < 0) { j = ddf_meta_find_pd(meta, NULL, 0xffffffff); pde = &meta->pdr->entry[j]; From owner-svn-src-head@FreeBSD.ORG Fri May 4 09:27:01 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 091E71065670; Fri, 4 May 2012 09:27:01 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DC8C38FC08; Fri, 4 May 2012 09:27:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q449R0hD095740; Fri, 4 May 2012 09:27:00 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q449R03S095729; Fri, 4 May 2012 09:27:00 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205040927.q449R03S095729@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 09:27:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234995 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 09:27:01 -0000 Author: tuexen Date: Fri May 4 09:27:00 2012 New Revision: 234995 URL: http://svn.freebsd.org/changeset/base/234995 Log: Use SCTP_PRINTF() instead of printf() in all SCTP sources. MFC after: 3 days Modified: head/sys/netinet/sctp_auth.c head/sys/netinet/sctp_bsd_addr.c head/sys/netinet/sctp_cc_functions.c head/sys/netinet/sctp_crc32.c head/sys/netinet/sctp_indata.c head/sys/netinet/sctp_input.c head/sys/netinet/sctp_os_bsd.h head/sys/netinet/sctp_output.c head/sys/netinet/sctp_pcb.c head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp_auth.c ============================================================================== --- head/sys/netinet/sctp_auth.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_auth.c Fri May 4 09:27:00 2012 (r234995) @@ -284,16 +284,16 @@ sctp_print_key(sctp_key_t * key, const c uint32_t i; if (key == NULL) { - printf("%s: [Null key]\n", str); + SCTP_PRINTF("%s: [Null key]\n", str); return; } - printf("%s: len %u, ", str, key->keylen); + SCTP_PRINTF("%s: len %u, ", str, key->keylen); if (key->keylen) { for (i = 0; i < key->keylen; i++) - printf("%02x", key->key[i]); - printf("\n"); + SCTP_PRINTF("%02x", key->key[i]); + SCTP_PRINTF("\n"); } else { - printf("[Null key]\n"); + SCTP_PRINTF("[Null key]\n"); } } @@ -303,16 +303,16 @@ sctp_show_key(sctp_key_t * key, const ch uint32_t i; if (key == NULL) { - printf("%s: [Null key]\n", str); + SCTP_PRINTF("%s: [Null key]\n", str); return; } - printf("%s: len %u, ", str, key->keylen); + SCTP_PRINTF("%s: len %u, ", str, key->keylen); if (key->keylen) { for (i = 0; i < key->keylen; i++) - printf("%02x", key->key[i]); - printf("\n"); + SCTP_PRINTF("%02x", key->key[i]); + SCTP_PRINTF("\n"); } else { - printf("[Null key]\n"); + SCTP_PRINTF("[Null key]\n"); } } Modified: head/sys/netinet/sctp_bsd_addr.c ============================================================================== --- head/sys/netinet/sctp_bsd_addr.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_bsd_addr.c Fri May 4 09:27:00 2012 (r234995) @@ -483,7 +483,7 @@ again_locked: } /* Sanity check */ if (thisend >= SCTP_PACKET_LOG_SIZE) { - printf("Insanity stops a log thisbegin:%d thisend:%d writers:%d lock:%d end:%d\n", + SCTP_PRINTF("Insanity stops a log thisbegin:%d thisend:%d writers:%d lock:%d end:%d\n", thisbegin, thisend, SCTP_BASE_VAR(packet_log_writers), Modified: head/sys/netinet/sctp_cc_functions.c ============================================================================== --- head/sys/netinet/sctp_cc_functions.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_cc_functions.c Fri May 4 09:27:00 2012 (r234995) @@ -1594,9 +1594,7 @@ sctp_hs_cwnd_increase(struct sctp_tcb *s cur_val = net->cwnd >> 10; indx = SCTP_HS_TABLE_SIZE - 1; -#ifdef SCTP_DEBUG - printf("HS CC CAlled.\n"); -#endif + if (cur_val < sctp_cwnd_adjust[0].cwnd) { /* normal mode */ if (net->net_ack > net->mtu) { Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_crc32.c Fri May 4 09:27:00 2012 (r234995) @@ -134,7 +134,7 @@ sctp_delayed_cksum(struct mbuf *m, uint3 offset += offsetof(struct sctphdr, checksum); if (offset + sizeof(uint32_t) > (uint32_t) (m->m_len)) { - printf("sctp_delayed_cksum(): m->len: %d, off: %d.\n", + SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n", (uint32_t) m->m_len, offset); /* * XXX this shouldn't happen, but if it does, the correct Modified: head/sys/netinet/sctp_indata.c ============================================================================== --- head/sys/netinet/sctp_indata.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_indata.c Fri May 4 09:27:00 2012 (r234995) @@ -328,7 +328,7 @@ sctp_mark_non_revokable(struct sctp_asso } SCTP_CALC_TSN_TO_GAP(gap, tsn, asoc->mapping_array_base_tsn); if (!SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap)) { - printf("gap:%x tsn:%x\n", gap, tsn); + SCTP_PRINTF("gap:%x tsn:%x\n", gap, tsn); sctp_print_mapping_array(asoc); #ifdef INVARIANTS panic("Things are really messed up now!!"); @@ -2308,7 +2308,7 @@ sctp_slide_mapping_arrays(struct sctp_tc #ifdef INVARIANTS for (i = 0; i < asoc->mapping_array_size; i++) { if ((asoc->mapping_array[i]) || (asoc->nr_mapping_array[i])) { - printf("Error Mapping array's not clean at clear\n"); + SCTP_PRINTF("Error Mapping array's not clean at clear\n"); sctp_print_mapping_array(asoc); } } @@ -2330,7 +2330,7 @@ sctp_slide_mapping_arrays(struct sctp_tc #ifdef INVARIANTS panic("impossible slide"); #else - printf("impossible slide lgap:%x slide_end:%x slide_from:%x? at:%d\n", + SCTP_PRINTF("impossible slide lgap:%x slide_end:%x slide_from:%x? at:%d\n", lgap, slide_end, slide_from, at); return; #endif @@ -2339,7 +2339,7 @@ sctp_slide_mapping_arrays(struct sctp_tc #ifdef INVARIANTS panic("would overrun buffer"); #else - printf("Gak, would have overrun map end:%d slide_end:%d\n", + SCTP_PRINTF("Gak, would have overrun map end:%d slide_end:%d\n", asoc->mapping_array_size, slide_end); slide_end = asoc->mapping_array_size; #endif @@ -3489,7 +3489,10 @@ sctp_strike_gap_ack_chunks(struct sctp_t continue; } } - /* printf("OK, we are now ready to FR this guy\n"); */ + /* + * SCTP_PRINTF("OK, we are now ready to FR this + * guy\n"); + */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) { sctp_log_fr(tp1->rec.data.TSN_seq, tp1->snd_count, 0, SCTP_FR_MARKED); @@ -3557,7 +3560,7 @@ sctp_strike_gap_ack_chunks(struct sctp_t tot_retrans++; /* mark the sending seq for possible subsequent FR's */ /* - * printf("Marking TSN for FR new value %x\n", + * SCTP_PRINTF("Marking TSN for FR new value %x\n", * (uint32_t)tpi->rec.data.TSN_seq); */ if (TAILQ_EMPTY(&asoc->send_queue)) { @@ -3709,11 +3712,10 @@ sctp_fs_audit(struct sctp_association *a TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { if (chk->sent < SCTP_DATAGRAM_RESEND) { - printf("Chk TSN:%u size:%d inflight cnt:%d\n", + SCTP_PRINTF("Chk TSN:%u size:%d inflight cnt:%d\n", chk->rec.data.TSN_seq, chk->send_size, - chk->snd_count - ); + chk->snd_count); inflight++; } else if (chk->sent == SCTP_DATAGRAM_RESEND) { resend++; @@ -3730,7 +3732,7 @@ sctp_fs_audit(struct sctp_association *a #ifdef INVARIANTS panic("Flight size-express incorrect? \n"); #else - printf("asoc->total_flight:%d cnt:%d\n", + SCTP_PRINTF("asoc->total_flight:%d cnt:%d\n", entry_flight, entry_cnt); SCTP_PRINTF("Flight size-express incorrect F:%d I:%d R:%d Ab:%d ACK:%d\n", @@ -3895,7 +3897,7 @@ sctp_express_handle_sack(struct sctp_tcb TAILQ_FOREACH_SAFE(tp1, &asoc->sent_queue, sctp_next, tp2) { if (SCTP_TSN_GE(cumack, tp1->rec.data.TSN_seq)) { if (tp1->sent == SCTP_DATAGRAM_UNSENT) { - printf("Warning, an unsent is now acked?\n"); + SCTP_PRINTF("Warning, an unsent is now acked?\n"); } if (tp1->sent < SCTP_DATAGRAM_ACKED) { /* @@ -4437,10 +4439,10 @@ sctp_handle_sack(struct mbuf *m, int off * no way, we have not even sent this TSN out yet. * Peer is hopelessly messed up with us. */ - printf("NEW cum_ack:%x send_s:%x is smaller or equal\n", + SCTP_PRINTF("NEW cum_ack:%x send_s:%x is smaller or equal\n", cum_ack, send_s); if (tp1) { - printf("Got send_s from tsn:%x + 1 of tp1:%p\n", + SCTP_PRINTF("Got send_s from tsn:%x + 1 of tp1:%p\n", tp1->rec.data.TSN_seq, tp1); } hopeless_peer: @@ -4681,10 +4683,8 @@ sctp_handle_sack(struct mbuf *m, int off * peer is either confused or we are under * attack. We must abort. */ - printf("Hopeless peer! biggest_tsn_acked:%x largest seq:%x\n", - biggest_tsn_acked, - send_s); - + SCTP_PRINTF("Hopeless peer! biggest_tsn_acked:%x largest seq:%x\n", + biggest_tsn_acked, send_s); goto hopeless_peer; } } @@ -4719,7 +4719,7 @@ sctp_handle_sack(struct mbuf *m, int off } if (tp1->sent == SCTP_DATAGRAM_UNSENT) { /* no more sent on list */ - printf("Warning, tp1->sent == %d and its now acked?\n", + SCTP_PRINTF("Warning, tp1->sent == %d and its now acked?\n", tp1->sent); } TAILQ_REMOVE(&asoc->sent_queue, tp1, sctp_next); Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_input.c Fri May 4 09:27:00 2012 (r234995) @@ -786,12 +786,12 @@ sctp_handle_abort(struct sctp_abort_chun sctp_abort_notification(stcb, 0, SCTP_SO_NOT_LOCKED); /* free the tcb */ #if defined(SCTP_PANIC_ON_ABORT) - printf("stcb:%p state:%d rport:%d net:%p\n", + SCTP_PRINTF("stcb:%p state:%d rport:%d net:%p\n", stcb, stcb->asoc.state, stcb->rport, net); if (!(stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET)) { panic("Received an ABORT"); } else { - printf("No panic its in state %x closed\n", stcb->asoc.state); + SCTP_PRINTF("No panic its in state %x closed\n", stcb->asoc.state); } #endif SCTP_STAT_INCR_COUNTER32(sctps_aborted); @@ -5792,9 +5792,9 @@ static void sctp_print_mbuf_chain(struct mbuf *m) { for (; m; m = SCTP_BUF_NEXT(m)) { - printf("%p: m_len = %ld\n", m, SCTP_BUF_LEN(m)); + SCTP_PRINTF("%p: m_len = %ld\n", m, SCTP_BUF_LEN(m)); if (SCTP_BUF_IS_EXTENDED(m)) - printf("%p: extend_size = %d\n", m, SCTP_BUF_EXTEND_SIZE(m)); + SCTP_PRINTF("%p: extend_size = %d\n", m, SCTP_BUF_EXTEND_SIZE(m)); } } Modified: head/sys/netinet/sctp_os_bsd.h ============================================================================== --- head/sys/netinet/sctp_os_bsd.h Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_os_bsd.h Fri May 4 09:27:00 2012 (r234995) @@ -157,12 +157,13 @@ MALLOC_DECLARE(SCTP_M_MCORE); */ #define USER_ADDR_NULL (NULL) /* FIX ME: temp */ +#define SCTP_PRINTF(params...) printf(params) #if defined(SCTP_DEBUG) #define SCTPDBG(level, params...) \ { \ do { \ if (SCTP_BASE_SYSCTL(sctp_debug_on) & level ) { \ - printf(params); \ + SCTP_PRINTF(params); \ } \ } while (0); \ } @@ -187,7 +188,6 @@ MALLOC_DECLARE(SCTP_M_MCORE); #define SCTPDBG_ADDR(level, addr) #define SCTPDBG_PKT(level, iph, sh) #endif -#define SCTP_PRINTF(params...) printf(params) #ifdef SCTP_LTRACE_CHUNKS #define SCTP_LTRACE_CHK(a, b, c, d) if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_CHUNK_ENABLE) SCTP_CTR6(KTR_SUBSYS, "SCTP:%d[%d]:%x-%x-%x-%x", SCTP_LOG_CHUNK_PROC, 0, a, b, c, d) @@ -196,12 +196,14 @@ MALLOC_DECLARE(SCTP_M_MCORE); #endif #ifdef SCTP_LTRACE_ERRORS -#define SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, file, err) if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ - printf("mbuf:%p inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ - m, inp, stcb, net, file, __LINE__, err); -#define SCTP_LTRACE_ERR_RET(inp, stcb, net, file, err) if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ - printf("inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ - inp, stcb, net, file, __LINE__, err); +#define SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, file, err) \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ + SCTP_PRINTF("mbuf:%p inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ + m, inp, stcb, net, file, __LINE__, err); +#define SCTP_LTRACE_ERR_RET(inp, stcb, net, file, err) \ + if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LTRACE_ERROR_ENABLE) \ + SCTP_PRINTF("inp:%p stcb:%p net:%p file:%x line:%d error:%d\n", \ + inp, stcb, net, file, __LINE__, err); #else #define SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, file, err) #define SCTP_LTRACE_ERR_RET(inp, stcb, net, file, err) Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_output.c Fri May 4 09:27:00 2012 (r234995) @@ -3062,7 +3062,7 @@ again_with_private_addresses_allowed: continue; } } else { - printf("Stcb is null - no print\n"); + SCTP_PRINTF("Stcb is null - no print\n"); } atomic_add_int(&sifa->refcount, 1); goto out; @@ -9493,7 +9493,7 @@ sctp_chunk_retransmission(struct sctp_in continue; } if (chk->data == NULL) { - printf("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n", + SCTP_PRINTF("TSN:%x chk->snd_count:%d chk->sent:%d can't retran - no data\n", chk->rec.data.TSN_seq, chk->snd_count, chk->sent); continue; } @@ -13840,7 +13840,7 @@ out_unlocked: if (inp) { sctp_validate_no_locks(inp); } else { - printf("Warning - inp is NULL so cant validate locks\n"); + SCTP_PRINTF("Warning - inp is NULL so cant validate locks\n"); } #endif if (top) { Modified: head/sys/netinet/sctp_pcb.c ============================================================================== --- head/sys/netinet/sctp_pcb.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctp_pcb.c Fri May 4 09:27:00 2012 (r234995) @@ -2426,8 +2426,8 @@ sctp_findassociation_ep_asconf(struct mb stcb = sctp_findassoc_by_vtag(NULL, to, ntohl(sh->v_tag), inp_p, netp, sh->src_port, sh->dest_port, 1, vrf_id, 0); /* - * printf("findassociation_ep_asconf: zero lookup address - * finds stcb 0x%x\n", (uint32_t)stcb); + * SCTP_PRINTF("findassociation_ep_asconf: zero lookup + * address finds stcb 0x%x\n", (uint32_t)stcb); */ } else { stcb = sctp_findassociation_ep_addr(inp_p, @@ -5745,7 +5745,7 @@ skip_sleep: if (v6 == 0) { sctp_input_with_port(m, off, 0); } else { - printf("V6 not yet supported\n"); + SCTP_PRINTF("V6 not yet supported\n"); sctp_m_freem(m); } CURVNET_RESTORE(); @@ -6276,8 +6276,8 @@ sctp_load_addresses_from_init(struct sct ptype = ntohs(phdr->param_type); plen = ntohs(phdr->param_length); /* - * printf("ptype => %0x, plen => %d\n", (uint32_t)ptype, - * (int)plen); + * SCTP_PRINTF("ptype => %0x, plen => %d\n", + * (uint32_t)ptype, (int)plen); */ if (offset + plen > limit) { break; Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Fri May 4 08:59:19 2012 (r234994) +++ head/sys/netinet/sctputil.c Fri May 4 09:27:00 2012 (r234995) @@ -1127,7 +1127,7 @@ sctp_print_mapping_array(struct sctp_ass { unsigned int i, limit; - printf("Mapping array size: %d, baseTSN: %8.8x, cumAck: %8.8x, highestTSN: (%8.8x, %8.8x).\n", + SCTP_PRINTF("Mapping array size: %d, baseTSN: %8.8x, cumAck: %8.8x, highestTSN: (%8.8x, %8.8x).\n", asoc->mapping_array_size, asoc->mapping_array_base_tsn, asoc->cumulative_tsn, @@ -1138,23 +1138,23 @@ sctp_print_mapping_array(struct sctp_ass break; } } - printf("Renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); + SCTP_PRINTF("Renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); for (i = 0; i < limit; i++) { - printf("%2.2x%c", asoc->mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); + SCTP_PRINTF("%2.2x%c", asoc->mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); } if (limit % 16) - printf("\n"); + SCTP_PRINTF("\n"); for (limit = asoc->mapping_array_size; limit > 1; limit--) { if (asoc->nr_mapping_array[limit - 1]) { break; } } - printf("Non renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); + SCTP_PRINTF("Non renegable mapping array (last %d entries are zero):\n", asoc->mapping_array_size - limit); for (i = 0; i < limit; i++) { - printf("%2.2x%c", asoc->nr_mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); + SCTP_PRINTF("%2.2x%c", asoc->nr_mapping_array[i], ((i + 1) % 16) ? ' ' : '\n'); } if (limit % 16) - printf("\n"); + SCTP_PRINTF("\n"); } int @@ -1292,7 +1292,7 @@ select_a_new_ep: goto no_stcb; } /* If we reach here huh? */ - printf("Unknown it ctl flag %x\n", + SCTP_PRINTF("Unknown it ctl flag %x\n", sctp_it_ctl.iterator_flags); sctp_it_ctl.iterator_flags = 0; } @@ -5392,7 +5392,7 @@ found_one: #ifdef INVARIANTS panic("refcnt already incremented"); #else - printf("refcnt already incremented?\n"); + SCTP_PRINTF("refcnt already incremented?\n"); #endif } else { atomic_add_int(&stcb->asoc.refcnt, 1); From owner-svn-src-head@FreeBSD.ORG Fri May 4 10:06:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DCE411065672; Fri, 4 May 2012 10:06:08 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C8E8E8FC14; Fri, 4 May 2012 10:06:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44A68xk097047; Fri, 4 May 2012 10:06:08 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44A687x097045; Fri, 4 May 2012 10:06:08 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041006.q44A687x097045@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 10:06:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234996 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 10:06:09 -0000 Author: tuexen Date: Fri May 4 10:06:08 2012 New Revision: 234996 URL: http://svn.freebsd.org/changeset/base/234996 Log: Call panic() only under INVARIANTS. MFC after: 3 days Modified: head/sys/netinet/sctp_crc32.c Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Fri May 4 09:27:00 2012 (r234995) +++ head/sys/netinet/sctp_crc32.c Fri May 4 10:06:08 2012 (r234996) @@ -124,7 +124,9 @@ void sctp_delayed_cksum(struct mbuf *m, uint32_t offset) { #if defined(SCTP_WITH_NO_CSUM) +#ifdef INVARIANTS panic("sctp_delayed_cksum() called when using no SCTP CRC."); +#endif #else uint32_t checksum; From owner-svn-src-head@FreeBSD.ORG Fri May 4 10:26:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9DC111065670; Fri, 4 May 2012 10:26:50 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89B978FC0C; Fri, 4 May 2012 10:26:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44AQooM097695; Fri, 4 May 2012 10:26:50 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44AQoQG097692; Fri, 4 May 2012 10:26:50 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041026.q44AQoQG097692@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 10:26:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234997 - head/lib/libc/net X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 10:26:50 -0000 Author: tuexen Date: Fri May 4 10:26:50 2012 New Revision: 234997 URL: http://svn.freebsd.org/changeset/base/234997 Log: Remove debug output. MFC after: 3 days Modified: head/lib/libc/net/sctp_sys_calls.c Modified: head/lib/libc/net/sctp_sys_calls.c ============================================================================== --- head/lib/libc/net/sctp_sys_calls.c Fri May 4 10:06:08 2012 (r234996) +++ head/lib/libc/net/sctp_sys_calls.c Fri May 4 10:26:50 2012 (r234997) @@ -800,7 +800,6 @@ continue_send: } sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs); if (sinfo->sinfo_assoc_id == 0) { - printf("Huh, can't get associd? TSNH!\n"); (void)setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X_COMPLETE, (void *)addrs, (socklen_t) addrs->sa_len); errno = ENOENT; From owner-svn-src-head@FreeBSD.ORG Fri May 4 15:31:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6971F106564A; Fri, 4 May 2012 15:31:36 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52B458FC08; Fri, 4 May 2012 15:31:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44FVa1u010238; Fri, 4 May 2012 15:31:36 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FVaYF010236; Fri, 4 May 2012 15:31:36 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205041531.q44FVaYF010236@svn.freebsd.org> From: Josh Paetzel Date: Fri, 4 May 2012 15:31:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:31:36 -0000 Author: jpaetzel Date: Fri May 4 15:31:35 2012 New Revision: 235005 URL: http://svn.freebsd.org/changeset/base/235005 Log: Use a unique zpool name during install, in the case of having another PC-BSD / FreeBSD zpool on the system for another install. Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:27:18 2012 (r235004) +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:31:35 2012 (r235005) @@ -216,7 +216,7 @@ fetch_file() fetch -s "${FETCHFILE}" >${SIZEFILE} SIZE="`cat ${SIZEFILE}`" - SIZE="`expr ${SIZE} / 1024`" + SIZE=$((SIZE/1024)) echo "FETCH: ${FETCHFILE}" echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} @@ -276,11 +276,22 @@ get_zpool_name() else # Need to generate a zpool name for this device NUM=`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` - NEWNAME="${BASENAME}${NUM}" + + # Is it used in another zpool? + while + z=1 + do + NEWNAME="${BASENAME}${NUM}" + zpool import | grep -q "${NEWNAME}" + if [ $? -ne 0 ] ; then break ; fi + NUM=$((NUM+1)) + done + + # Now save the new tank name mkdir -p ${TMPDIR}/.zpools/`dirname $DEVICE` echo "$NEWNAME" >${TMPDIR}/.zpools/${DEVICE} echo "${NEWNAME}" - return + return 0 fi }; From owner-svn-src-head@FreeBSD.ORG Fri May 4 15:36:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F5B5106564A; Fri, 4 May 2012 15:36:52 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 299978FC18; Fri, 4 May 2012 15:36:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44FaqiB010445; Fri, 4 May 2012 15:36:52 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44FapN5010442; Fri, 4 May 2012 15:36:51 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205041536.q44FapN5010442@svn.freebsd.org> From: Josh Paetzel Date: Fri, 4 May 2012 15:36:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235006 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:36:52 -0000 Author: jpaetzel Date: Fri May 4 15:36:51 2012 New Revision: 235006 URL: http://svn.freebsd.org/changeset/base/235006 Log: Add powerpc / powerpc64 support to pc-sysinstall. This patch will autodetect if on powerpc and use the APM gpart GEOM class automaticaly. At this time support for full disk installation is the only supported scheme. Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Fri May 4 15:31:35 2012 (r235005) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Fri May 4 15:36:51 2012 (r235006) @@ -177,6 +177,8 @@ setup_gpart_partitions() # Lets read in the config file now and setup our partitions if [ "${_pType}" = "gpt" ] ; then CURPART="2" + elif [ "${_pType}" = "apm" ] ; then + CURPART="3" else PARTLETTER="a" CURPART="1" @@ -255,6 +257,9 @@ setup_gpart_partitions() if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then export FOUNDROOT="0" fi + if [ "${CURPART}" = "3" -a "$_pType" = "apm" ] ; then + export FOUNDROOT="0" + fi if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then export FOUNDROOT="0" fi @@ -269,6 +274,9 @@ setup_gpart_partitions() if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then exit_err "/boot partition must be first partition" fi + if [ "${CURPART}" != "3" -a "${_pType}" = "apm" ] ; then + exit_err "/boot partition must be first partition" + fi if [ "${CURPART}" != "1" -a "${_pType}" = "mbr" ] ; then exit_err "/boot partition must be first partition" fi @@ -288,6 +296,8 @@ setup_gpart_partitions() # Get any extra options for this fs / line if [ "${_pType}" = "gpt" ] ; then get_fs_line_xvars "${_pDisk}p${CURPART}" "${STRING}" + elif [ "${_pType}" = "apm" ] ; then + get_fs_line_xvars "${_pDisk}s${CURPART}" "${STRING}" else get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" fi @@ -298,6 +308,8 @@ setup_gpart_partitions() if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") + elif [ "${_pType}" = "apm" ] ; then + XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}s${CURPART}") else XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}${PARTLETTER}") fi @@ -323,6 +335,9 @@ setup_gpart_partitions() elif [ "${_pType}" = "gptslice" ]; then sleep 2 rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_wSlice}" + elif [ "${_pType}" = "apm" ]; then + sleep 2 + rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" else sleep 2 rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}" @@ -352,6 +367,18 @@ setup_gpart_partitions() if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass fi + elif [ "${_pType}" = "apm" ] ; then + _dFile="`echo $_pDisk | sed 's|/|-|g'`" + echo "${FS}#${MNT}#${ENC}#${PLABEL}#GPT#${XTRAOPTS}" >${PARTDIR}/${_dFile}s${CURPART} + + # Clear out any headers + sleep 2 + dd if=/dev/zero of=${_pDisk}s${CURPART} count=2048 2>/dev/null + + # If we have a enc password, save it as well + if [ -n "${ENCPASS}" ] ; then + echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}s${CURPART}-encpass + fi else # MBR Partition or GPT slice _dFile="`echo $_wSlice | sed 's|/|-|g'`" @@ -368,9 +395,10 @@ setup_gpart_partitions() # Increment our parts counter - if [ "$_pType" = "gpt" ] ; then + if [ "$_pType" = "gpt" -o "$_pType" = "apm" ] ; then CURPART=$((CURPART+1)) - # If this is a gpt partition, we can continue and skip the MBR part letter stuff + # If this is a gpt/apm partition, + # we can continue and skip the MBR part letter stuff continue else CURPART=$((CURPART+1)) @@ -437,6 +465,9 @@ populate_disk_label() if [ "$type" = "mbr" ] ; then wrkslice="${diskid}s${slicenum}" fi + if [ "$type" = "apm" ] ; then + wrkslice="${diskid}s${slicenum}" + fi if [ "$type" = "gpt" -o "$type" = "gptslice" ] ; then wrkslice="${diskid}p${slicenum}" fi @@ -474,6 +505,9 @@ setup_disk_label() if [ "$type" = "gpt" -a ! -e "${disk}p${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi + if [ "$type" = "apm" -a ! -e "${disk}s${pnum}" ] ; then + exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" + fi if [ "$type" = "gptslice" -a ! -e "${disk}p${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:31:35 2012 (r235005) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:36:51 2012 (r235006) @@ -464,6 +464,12 @@ setup_disk_slice() # Found our flag to commit this disk setup / lets do sanity check and do it if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ] then + # Make sure we are only installing ppc to full disk + if [ `uname -m` = "powerpc" -o `uname -m` = "powerpc64" ]; then + if [ "$PTYPE" != "all" ] ; then + exit_err "powerpc can only be installed to a full disk" + fi + fi case ${PTYPE} in all) @@ -488,6 +494,12 @@ setup_disk_slice() tmpSLICE="${DISK}p1" fi + if [ `uname -m` = "powerpc" -o `uname -m` = "powerpc64" ] + then + PSCHEME="APM" + tmpSLICE="${DISK}s1" + fi + run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}" ;; @@ -597,6 +609,30 @@ clear_backup_gpt_table() rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=`diskinfo ${1} | awk '{print int($3 / (1024*1024)) - 4;}'`" } ; +# Function which runs gpart and creates a single large APM partition scheme +init_apm_full_disk() +{ + _intDISK=$1 + + # Set our sysctl so we can overwrite any geom using drives + sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} + + # Stop any journaling + stop_gjournal "${_intDISK}" + + # Remove any existing partitions + delete_all_gpart "${_intDISK}" + + sleep 2 + + echo_log "Running gpart on ${_intDISK}" + rc_halt "gpart create -s APM ${_intDISK}" + rc_halt "gpart add -s 800k -t freebsd-boot ${_intDISK}" + + echo_log "Stamping boot sector on ${_intDISK}" + rc_halt "gpart bootcode -p /boot/boot1.hfs -i 1 ${_intDISK}" + +} # Function which runs gpart and creates a single large GPT partition scheme init_gpt_full_disk() @@ -670,7 +706,10 @@ run_gpart_full() BOOT=$2 SCHEME=$3 - if [ "$SCHEME" = "MBR" ] ; then + if [ "$SCHEME" = "APM" ] ; then + init_apm_full_disk "$DISK" + slice=`echo "${DISK}:1:apm" | sed 's|/|-|g'` + elif [ "$SCHEME" = "MBR" ] ; then init_mbr_full_disk "$DISK" "$BOOT" slice=`echo "${DISK}:1:mbr" | sed 's|/|-|g'` else From owner-svn-src-head@FreeBSD.ORG Fri May 4 15:39:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3037F1065673; Fri, 4 May 2012 15:39:42 +0000 (UTC) (envelope-from jpaetzel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1AD568FC21; Fri, 4 May 2012 15:39:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44FdfgL010612; Fri, 4 May 2012 15:39:41 GMT (envelope-from jpaetzel@svn.freebsd.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44Fdff6010610; Fri, 4 May 2012 15:39:41 GMT (envelope-from jpaetzel@svn.freebsd.org) Message-Id: <201205041539.q44Fdff6010610@svn.freebsd.org> From: Josh Paetzel Date: Fri, 4 May 2012 15:39:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235008 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:39:42 -0000 Author: jpaetzel Date: Fri May 4 15:39:41 2012 New Revision: 235008 URL: http://svn.freebsd.org/changeset/base/235008 Log: Add bootcamp bootloader stamp Submitted by: kmoore Obtained from: PC-BSD MFC after: 3 days Sponsored by: iXsystems Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh ============================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:38:47 2012 (r235007) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Fri May 4 15:39:41 2012 (r235008) @@ -766,6 +766,10 @@ run_gpart_gpt_part() # Init the MBR partition rc_halt "gpart create -s BSD ${DISK}p${slicenum}" + # Stamp the bootloader + sleep 4 + rc_halt "gpart bootcode -b /boot/boot ${DISK}p${slicenum}" + # Set the slice to the format we'll be using for gpart later slice=`echo "${1}:${3}:gptslice" | sed 's|/|-|g'` From owner-svn-src-head@FreeBSD.ORG Fri May 4 15:49:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3CF8106566B; Fri, 4 May 2012 15:49:08 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE3DE8FC16; Fri, 4 May 2012 15:49:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44Fn8Qw010973; Fri, 4 May 2012 15:49:08 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44Fn8bH010969; Fri, 4 May 2012 15:49:08 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041549.q44Fn8bH010969@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 15:49:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235009 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 15:49:09 -0000 Author: tuexen Date: Fri May 4 15:49:08 2012 New Revision: 235009 URL: http://svn.freebsd.org/changeset/base/235009 Log: Add support for SCTP_STREAM_CHANGE_EVENT, SCTP_ASSOC_RESET_EVENT as required by RFC 6525. This also fixes SCTP_STREAM_RESET_EVENT. MFC after: 3 days Modified: head/sys/netinet/sctp.h head/sys/netinet/sctp_usrreq.c head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp.h ============================================================================== --- head/sys/netinet/sctp.h Fri May 4 15:39:41 2012 (r235008) +++ head/sys/netinet/sctp.h Fri May 4 15:49:08 2012 (r235009) @@ -511,35 +511,37 @@ struct sctp_error_unrecognized_chunk { /* * PCB Features (in sctp_features bitmask) */ -#define SCTP_PCB_FLAGS_DO_NOT_PMTUD 0x00000001 -#define SCTP_PCB_FLAGS_EXT_RCVINFO 0x00000002 /* deprecated */ -#define SCTP_PCB_FLAGS_DONOT_HEARTBEAT 0x00000004 -#define SCTP_PCB_FLAGS_FRAG_INTERLEAVE 0x00000008 -#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS 0x00000010 -#define SCTP_PCB_FLAGS_DO_ASCONF 0x00000020 -#define SCTP_PCB_FLAGS_AUTO_ASCONF 0x00000040 -#define SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE 0x00000080 +#define SCTP_PCB_FLAGS_DO_NOT_PMTUD 0x00000001 +#define SCTP_PCB_FLAGS_EXT_RCVINFO 0x00000002 /* deprecated */ +#define SCTP_PCB_FLAGS_DONOT_HEARTBEAT 0x00000004 +#define SCTP_PCB_FLAGS_FRAG_INTERLEAVE 0x00000008 +#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS 0x00000010 +#define SCTP_PCB_FLAGS_DO_ASCONF 0x00000020 +#define SCTP_PCB_FLAGS_AUTO_ASCONF 0x00000040 +#define SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE 0x00000080 /* socket options */ -#define SCTP_PCB_FLAGS_NODELAY 0x00000100 -#define SCTP_PCB_FLAGS_AUTOCLOSE 0x00000200 -#define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x00000400 /* deprecated */ -#define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x00000800 -#define SCTP_PCB_FLAGS_RECVPADDREVNT 0x00001000 -#define SCTP_PCB_FLAGS_RECVPEERERR 0x00002000 -#define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x00004000 -#define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x00008000 -#define SCTP_PCB_FLAGS_ADAPTATIONEVNT 0x00010000 -#define SCTP_PCB_FLAGS_PDAPIEVNT 0x00020000 -#define SCTP_PCB_FLAGS_AUTHEVNT 0x00040000 -#define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00080000 -#define SCTP_PCB_FLAGS_NO_FRAGMENT 0x00100000 -#define SCTP_PCB_FLAGS_EXPLICIT_EOR 0x00400000 -#define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x00800000 -#define SCTP_PCB_FLAGS_MULTIPLE_ASCONFS 0x01000000 -#define SCTP_PCB_FLAGS_PORTREUSE 0x02000000 -#define SCTP_PCB_FLAGS_DRYEVNT 0x04000000 -#define SCTP_PCB_FLAGS_RECVRCVINFO 0x08000000 -#define SCTP_PCB_FLAGS_RECVNXTINFO 0x10000000 +#define SCTP_PCB_FLAGS_NODELAY 0x00000100 +#define SCTP_PCB_FLAGS_AUTOCLOSE 0x00000200 +#define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x00000400 /* deprecated */ +#define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x00000800 +#define SCTP_PCB_FLAGS_RECVPADDREVNT 0x00001000 +#define SCTP_PCB_FLAGS_RECVPEERERR 0x00002000 +#define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x00004000 +#define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x00008000 +#define SCTP_PCB_FLAGS_ADAPTATIONEVNT 0x00010000 +#define SCTP_PCB_FLAGS_PDAPIEVNT 0x00020000 +#define SCTP_PCB_FLAGS_AUTHEVNT 0x00040000 +#define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00080000 +#define SCTP_PCB_FLAGS_NO_FRAGMENT 0x00100000 +#define SCTP_PCB_FLAGS_EXPLICIT_EOR 0x00400000 +#define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x00800000 +#define SCTP_PCB_FLAGS_MULTIPLE_ASCONFS 0x01000000 +#define SCTP_PCB_FLAGS_PORTREUSE 0x02000000 +#define SCTP_PCB_FLAGS_DRYEVNT 0x04000000 +#define SCTP_PCB_FLAGS_RECVRCVINFO 0x08000000 +#define SCTP_PCB_FLAGS_RECVNXTINFO 0x10000000 +#define SCTP_PCB_FLAGS_ASSOC_RESETEVNT 0x20000000 +#define SCTP_PCB_FLAGS_STREAM_CHANGEEVNT 0x40000000 /*- * mobility_features parameters (by micchie).Note @@ -547,9 +549,9 @@ struct sctp_error_unrecognized_chunk { * sctp_mobility_features flags.. not the sctp_features * flags. */ -#define SCTP_MOBILITY_BASE 0x00000001 -#define SCTP_MOBILITY_FASTHANDOFF 0x00000002 -#define SCTP_MOBILITY_PRIM_DELETED 0x00000004 +#define SCTP_MOBILITY_BASE 0x00000001 +#define SCTP_MOBILITY_FASTHANDOFF 0x00000002 +#define SCTP_MOBILITY_PRIM_DELETED 0x00000004 #define SCTP_SMALLEST_PMTU 512 /* smallest pmtu allowed when disabling PMTU Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Fri May 4 15:39:41 2012 (r235008) +++ head/sys/netinet/sctp_usrreq.c Fri May 4 15:49:08 2012 (r235009) @@ -2983,6 +2983,12 @@ flags_out: SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTSUP); error = ENOTSUP; break; + case SCTP_ASSOC_RESET_EVENT: + event_type = SCTP_PCB_FLAGS_ASSOC_RESETEVNT; + break; + case SCTP_STREAM_CHANGE_EVENT: + event_type = SCTP_PCB_FLAGS_STREAM_CHANGEEVNT; + break; default: event_type = 0; SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); @@ -5379,6 +5385,12 @@ sctp_setopt(struct socket *so, int optna SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTSUP); error = ENOTSUP; break; + case SCTP_ASSOC_RESET_EVENT: + event_type = SCTP_PCB_FLAGS_ASSOC_RESETEVNT; + break; + case SCTP_STREAM_CHANGE_EVENT: + event_type = SCTP_PCB_FLAGS_STREAM_CHANGEEVNT; + break; default: event_type = 0; SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Fri May 4 15:39:41 2012 (r235008) +++ head/sys/netinet/sctputil.c Fri May 4 15:49:08 2012 (r235009) @@ -3214,7 +3214,7 @@ sctp_notify_stream_reset_add(struct sctp struct sctp_stream_change_event *stradd; int len; - if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_CHANGEEVNT)) { /* event not enabled */ return; } @@ -3275,7 +3275,7 @@ sctp_notify_stream_reset_tsn(struct sctp struct sctp_assoc_reset_event *strasoc; int len; - if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_STREAM_RESETEVNT)) { + if (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_ASSOC_RESETEVNT)) { /* event not enabled */ return; } From owner-svn-src-head@FreeBSD.ORG Fri May 4 16:00:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C5458106564A; Fri, 4 May 2012 16:00:24 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 962008FC08; Fri, 4 May 2012 16:00:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44G0OR3011533; Fri, 4 May 2012 16:00:24 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44G0O1S011532; Fri, 4 May 2012 16:00:24 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201205041600.q44G0O1S011532@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 4 May 2012 16:00:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235013 - in head/sys/powerpc: aim include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:00:25 -0000 Author: nwhitehorn Date: Fri May 4 16:00:22 2012 New Revision: 235013 URL: http://svn.freebsd.org/changeset/base/235013 Log: Fix final bugs in memory barriers on PowerPC: - Use isync/lwsync unconditionally for acquire/release. Use of isync guarantees a complete memory barrier, which is important for serialization of bus space accesses with mutexes on multi-processor systems. - Go back to using sync as the I/O memory barrier, which solves the same problem as above with respect to mutex release using lwsync, while not penalizing non-I/O operations like a return to sync on the atomic release operations would. - Place an acquisition barrier around thread lock acquisition in cpu_switchin(). Modified: head/sys/powerpc/aim/swtch32.S head/sys/powerpc/aim/swtch64.S head/sys/powerpc/include/atomic.h head/sys/powerpc/include/pio.h Modified: head/sys/powerpc/aim/swtch32.S ============================================================================== --- head/sys/powerpc/aim/swtch32.S Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/aim/swtch32.S Fri May 4 16:00:22 2012 (r235013) @@ -124,7 +124,8 @@ cpu_switchin: blocked_loop: lwz %r7,TD_LOCK(%r2) cmpw %r6,%r7 - beq blocked_loop + beq- blocked_loop + isync #endif mfsprg %r7,0 /* Get the pcpu pointer */ Modified: head/sys/powerpc/aim/swtch64.S ============================================================================== --- head/sys/powerpc/aim/swtch64.S Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/aim/swtch64.S Fri May 4 16:00:22 2012 (r235013) @@ -150,7 +150,8 @@ cpu_switchin: blocked_loop: ld %r7,TD_LOCK(%r13) cmpd %r6,%r7 - beq blocked_loop + beq- blocked_loop + isync #endif mfsprg %r7,0 /* Get the pcpu pointer */ Modified: head/sys/powerpc/include/atomic.h ============================================================================== --- head/sys/powerpc/include/atomic.h Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/include/atomic.h Fri May 4 16:00:22 2012 (r235013) @@ -51,13 +51,8 @@ * with the atomic lXarx/stXcx. sequences below. See Appendix B.2 of Book II * of the architecture manual. */ -#ifdef __powerpc64__ -#define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory") -#define __ATOMIC_ACQ() __asm __volatile("lwsync" : : : "memory") -#else #define __ATOMIC_REL() __asm __volatile("lwsync" : : : "memory") #define __ATOMIC_ACQ() __asm __volatile("isync" : : : "memory") -#endif /* * atomic_add(p, v) Modified: head/sys/powerpc/include/pio.h ============================================================================== --- head/sys/powerpc/include/pio.h Fri May 4 15:57:05 2012 (r235012) +++ head/sys/powerpc/include/pio.h Fri May 4 16:00:22 2012 (r235013) @@ -39,7 +39,12 @@ * I/O macros. */ -#define powerpc_iomb() __asm __volatile("eieio" : : : "memory") +/* + * Use sync so that bus space operations cannot sneak out the bottom of + * mutex-protected sections (mutex release does not guarantee completion of + * accesses to caching-inhibited memory on some systems) + */ +#define powerpc_iomb() __asm __volatile("sync" : : : "memory") static __inline void __outb(volatile u_int8_t *a, u_int8_t v) From owner-svn-src-head@FreeBSD.ORG Fri May 4 16:00:40 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0EAD2106566B; Fri, 4 May 2012 16:00:40 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ECFBA8FC14; Fri, 4 May 2012 16:00:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44G0duk011590; Fri, 4 May 2012 16:00:39 GMT (envelope-from ambrisko@svn.freebsd.org) Received: (from ambrisko@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44G0dk9011584; Fri, 4 May 2012 16:00:39 GMT (envelope-from ambrisko@svn.freebsd.org) Message-Id: <201205041600.q44G0dk9011584@svn.freebsd.org> From: Doug Ambrisko Date: Fri, 4 May 2012 16:00:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235014 - head/sys/dev/mfi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:00:40 -0000 Author: ambrisko Date: Fri May 4 16:00:39 2012 New Revision: 235014 URL: http://svn.freebsd.org/changeset/base/235014 Log: First fix pr 167226: ThunderBolt cannot read sector >= 2^32 or 2^21 with supplied patch. Second the bigger change, fix RAID operation on ThunderBolt base card such as physically removing a disk from a RAID and replacing it. The current situation is the RAID firmware effectively hangs waiting for an acknowledgement from the driver. This is due to the firmware support of the driver actually accessing the RAID from under the firmware. This is an interesting feature that the FreeBSD driver does not use. However, when the firmare detects the driver has attached it then expects the driver will synchronize LD's with the firmware. If the driver does not sync. then the management part of the firmware will hang waiting for it so a pulled driver will listed as still there. The fix for this problem isn't extremely difficult. However, figuring out why some of the code was the way it was and then redoing it was involved. Not have a spec. made it harder to try to figure out. The existing driver would send a MFI_DCMD_LD_MAP_GET_INFO command in write mode to acknowledge a LD state change. In read mode it gets the RAID map from the firmware. The FreeBSD driver doesn't do that currently. It could be added in the future with the appropriate structures. To simplify things, get the current LD state and then build the MFI_DCMD_LD_MAP_GET_INFO/write command so that it sends an acknowledgement for each LD. The map would probably state which LD's changed so then the driver could probably just acknowledge the LD's that changed versus all. This doesn't seem to be a problem. When a MFI_DCMD_LD_MAP_GET_INFO/write command is sent to the firmware, it will complete later when a change to the LD's happen. So it is very much like an AEN command returning when something happened. When the MFI_DCMD_LD_MAP_GET_INFO/write command completes, we refire the sync'ing of the LD state. This needs to be done in as an event so that MFI_DCMD_LD_GET_LIST can wait for that command to complete before issuing the MFI_DCMD_LD_MAP_GET_INFO/write. The prior code didn't use the call-back function and tried to intercept the MFI_DCMD_LD_MAP_GET_INFO/write command when processing an interrupt. This added a bunch of code complexity to the interrupt handler. Using the call-back that is done for other commands got rid of this need. So the interrupt handler is greatly simplified. It seems that even commands that shouldn't be acknowledged end up in the interrupt handler. To deal with this, code was added to check to see if a command is in the busy queue or not. This might have contributed to the interrupt storm happening without MSI enabled on these cards. Note that MFI_DCMD_LD_MAP_GET_INFO/read returns right away. It would be interesting to see what other complexity could be removed from the ThunderBolt driver that really isn't needed in our mode of operation. Letting the RAID firmware do all of the I/O to disks is a lot faster since it can use its caches. It greatly simplifies what the driver has to do and potential bugs if the driver and firmware are not in sync. Simplify the aen_abort/cm_map_abort and put it in the softc versus in the command structure. This should get merged to 9 before the driver is merged to 8. PR: 167226 Submitted by: Petr Lampa MFC after: 3 days Modified: head/sys/dev/mfi/mfi.c head/sys/dev/mfi/mfi_debug.c head/sys/dev/mfi/mfi_tbolt.c head/sys/dev/mfi/mfireg.h head/sys/dev/mfi/mfivar.h Modified: head/sys/dev/mfi/mfi.c ============================================================================== --- head/sys/dev/mfi/mfi.c Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfi.c Fri May 4 16:00:39 2012 (r235014) @@ -90,8 +90,6 @@ static int mfi_get_controller_info(struc static int mfi_get_log_state(struct mfi_softc *, struct mfi_evt_log_state **); static int mfi_parse_entries(struct mfi_softc *, int, int); -static int mfi_dcmd_command(struct mfi_softc *, struct mfi_command **, - uint32_t, void **, size_t); static void mfi_data_cb(void *, bus_dma_segment_t *, int, int); static void mfi_startup(void *arg); static void mfi_intr(void *arg); @@ -377,6 +375,7 @@ mfi_attach(struct mfi_softc *sc) TAILQ_INIT(&sc->mfi_syspd_tqh); TAILQ_INIT(&sc->mfi_evt_queue); TASK_INIT(&sc->mfi_evt_task, 0, mfi_handle_evt, sc); + TASK_INIT(&sc->mfi_map_sync_task, 0, mfi_handle_map_sync, sc); TAILQ_INIT(&sc->mfi_aen_pids); TAILQ_INIT(&sc->mfi_cam_ccbq); @@ -696,7 +695,6 @@ mfi_attach(struct mfi_softc *sc) return (EINVAL); } sc->mfi_enable_intr(sc); - sc->map_id = 0; } else { if ((error = mfi_comms_init(sc)) != 0) return (error); @@ -762,6 +760,10 @@ mfi_attach(struct mfi_softc *sc) callout_reset(&sc->mfi_watchdog_callout, MFI_CMD_TIMEOUT * hz, mfi_timeout, sc); + if (sc->mfi_flags & MFI_FLAGS_TBOLT) { + mfi_tbolt_sync_map_info(sc); + } + return (0); } @@ -845,7 +847,7 @@ mfi_release_command(struct mfi_command * mfi_enqueue_free(cm); } -static int +int mfi_dcmd_command(struct mfi_softc *sc, struct mfi_command **cmp, uint32_t opcode, void **bufp, size_t bufsize) { @@ -1286,8 +1288,8 @@ mfi_shutdown(struct mfi_softc *sc) if (sc->mfi_aen_cm != NULL) mfi_abort(sc, sc->mfi_aen_cm); - if (sc->map_update_cmd != NULL) - mfi_abort(sc, sc->map_update_cmd); + if (sc->mfi_map_sync_cm != NULL) + mfi_abort(sc, sc->mfi_map_sync_cm); dcmd = &cm->cm_frame->dcmd; dcmd->header.flags = MFI_FRAME_DIR_NONE; @@ -1664,9 +1666,9 @@ mfi_aen_complete(struct mfi_command *cm) if (sc->mfi_aen_cm == NULL) return; - if (sc->mfi_aen_cm->cm_aen_abort || + if (sc->cm_aen_abort || hdr->cmd_status == MFI_STAT_INVALID_STATUS) { - sc->mfi_aen_cm->cm_aen_abort = 0; + sc->cm_aen_abort = 0; aborted = 1; } else { sc->mfi_aen_triggered = 1; @@ -2385,7 +2387,9 @@ mfi_abort(struct mfi_softc *sc, struct m cm->cm_flags = MFI_CMD_POLLED; if (sc->mfi_aen_cm) - sc->mfi_aen_cm->cm_aen_abort = 1; + sc->cm_aen_abort = 1; + if (sc->mfi_map_sync_cm) + sc->cm_map_abort = 1; mfi_mapcmd(sc, cm); mfi_release_command(cm); @@ -2394,6 +2398,11 @@ mfi_abort(struct mfi_softc *sc, struct m 5 * hz); i++; } + while (i < 5 && sc->mfi_map_sync_cm != NULL) { + msleep(&sc->mfi_map_sync_cm, &sc->mfi_io_lock, 0, "mfiabort", + 5 * hz); + i++; + } return (0); } @@ -3549,9 +3558,9 @@ mfi_timeout(void *data) } mtx_lock(&sc->mfi_io_lock); TAILQ_FOREACH(cm, &sc->mfi_busy, cm_link) { - if (sc->mfi_aen_cm == cm) + if (sc->mfi_aen_cm == cm || sc->mfi_map_sync_cm == cm) continue; - if ((sc->mfi_aen_cm != cm) && (cm->cm_timestamp < deadline)) { + if (cm->cm_timestamp < deadline) { if (sc->adpreset != 0 && sc->issuepend_done == 0) { cm->cm_timestamp = time_uptime; } else { Modified: head/sys/dev/mfi/mfi_debug.c ============================================================================== --- head/sys/dev/mfi/mfi_debug.c Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfi_debug.c Fri May 4 16:00:39 2012 (r235014) @@ -172,6 +172,9 @@ mfi_print_dcmd(struct mfi_softc *sc, dev case MFI_DCMD_CLUSTER_RESET_LD: opcode = "CLUSTER_RESET_LD"; break; + case MFI_DCMD_LD_MAP_GET_INFO: + opcode = "LD_MAP_GET_INFO"; + break; default: opcode = "UNKNOWN"; break; Modified: head/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:00:39 2012 (r235014) @@ -82,7 +82,8 @@ map_tbolt_cmd_status(struct mfi_command static void mfi_issue_pending_cmds_again (struct mfi_softc *sc); static void mfi_kill_hba (struct mfi_softc *sc); static void mfi_process_fw_state_chg_isr(void *arg); -uint8_t mfi_tbolt_get_map_info(struct mfi_softc *sc); +static void mfi_sync_map_complete(struct mfi_command *); +static void mfi_queue_map_sync(struct mfi_softc *sc); #define MFI_FUSION_ENABLE_INTERRUPT_MASK (0x00000008) @@ -627,10 +628,11 @@ mfi_tbolt_return_cmd(struct mfi_softc *s TAILQ_INSERT_TAIL(&sc->mfi_cmd_tbolt_tqh, cmd, next); } -void mfi_tbolt_complete_cmd(struct mfi_softc *sc) +void +mfi_tbolt_complete_cmd(struct mfi_softc *sc) { struct mfi_mpi2_reply_header *desc, *reply_desc; - struct mfi_command *cmd_mfi; /* For MFA Cmds */ + struct mfi_command *cmd_mfi, *cmd_mfi_check; /* For MFA Cmds */ struct mfi_cmd_tbolt *cmd_tbolt; uint16_t smid; uint8_t reply_descript_type; @@ -657,7 +659,6 @@ void mfi_tbolt_complete_cmd(struct mfi_s /* Read Reply descriptor */ while ((val.u.low != 0xFFFFFFFF) && (val.u.high != 0xFFFFFFFF)) { - smid = reply_desc->SMID; if (!smid || smid > sc->mfi_max_fw_cmds + 1) { device_printf(sc->mfi_dev, "smid is %x. Cannot " @@ -669,66 +670,20 @@ void mfi_tbolt_complete_cmd(struct mfi_s cmd_mfi = &sc->mfi_commands[cmd_tbolt->sync_cmd_idx]; scsi_io_req = cmd_tbolt->io_request; - /* Check if internal commands */ status = cmd_mfi->cm_frame->dcmd.header.cmd_status; extStatus = cmd_mfi->cm_frame->dcmd.header.scsi_status; + map_tbolt_cmd_status(cmd_mfi, status, extStatus); - switch (scsi_io_req->Function) { - case MPI2_FUNCTION_LD_IO_REQUEST: - /* Regular Path IO. */ - /* Map the Fw Error Status. */ - map_tbolt_cmd_status(cmd_mfi, status, - extStatus); - if ((cmd_mfi->cm_frame->dcmd.opcode - == MFI_DCMD_LD_MAP_GET_INFO) - && (cmd_mfi->cm_frame->dcmd.mbox[1] == 1)) { - if (cmd_mfi->cm_frame->header.cmd_status - != 0) - device_printf(sc->mfi_dev, - "map sync failed\n"); - else { - sc->map_id++; - device_printf(sc->mfi_dev, - "map sync completed\n"); - mfi_release_command(cmd_mfi); - } - } - if ((cmd_mfi->cm_flags & MFI_ON_MFIQ_BUSY) - == MFI_ON_MFIQ_BUSY - && (cmd_mfi->cm_flags & MFI_CMD_POLLED) == 0) { - /* BHARAT poll workaround */ - mfi_remove_busy(cmd_mfi); - cmd_mfi->cm_error = 0; - mfi_complete(sc, cmd_mfi); - } - mfi_tbolt_return_cmd(sc, cmd_tbolt); - break; - case MPI2_FUNCTION_PASSTHRU_IO_REQUEST: - map_tbolt_cmd_status(cmd_mfi, status, extStatus); - if ((cmd_mfi->cm_frame->dcmd.opcode - == MFI_DCMD_LD_MAP_GET_INFO) - && (cmd_mfi->cm_frame->dcmd.mbox[1] == 1)) { - if (cmd_mfi->cm_frame->header.cmd_status != 0) - device_printf(sc->mfi_dev, - "map sync failed\n"); - else { - sc->map_id++; - device_printf(sc->mfi_dev, - "map sync completed\n"); - mfi_release_command(cmd_mfi); - } - } - if ((cmd_mfi->cm_flags & MFI_ON_MFIQ_BUSY) - == MFI_ON_MFIQ_BUSY - && (cmd_mfi->cm_flags & MFI_CMD_POLLED) == 0) { - /* BHARAT poll workaround */ + /* remove command from busy queue if not polled */ + TAILQ_FOREACH(cmd_mfi_check, &sc->mfi_busy, cm_link) { + if (cmd_mfi_check == cmd_mfi) { mfi_remove_busy(cmd_mfi); - cmd_mfi->cm_error = 0; - mfi_complete(sc, cmd_mfi); + break; } - mfi_tbolt_return_cmd(sc, cmd_tbolt); - break; } + cmd_mfi->cm_error = 0; + mfi_complete(sc, cmd_mfi); + mfi_tbolt_return_cmd(sc, cmd_tbolt); sc->last_reply_idx++; if (sc->last_reply_idx >= sc->mfi_max_fw_cmds) { @@ -949,7 +904,7 @@ mfi_tbolt_build_cdb(struct mfi_softc *sc lba_lo = mfi_cmd->cm_frame->io.lba_lo; lba_hi = mfi_cmd->cm_frame->io.lba_hi; - if ((num_lba <= 0xFF) && (lba_lo <= 0x1FFFFF)) { + if (lba_hi == 0 && (num_lba <= 0xFF) && (lba_lo <= 0x1FFFFF)) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) /* Read 6 or Write 6 */ cdb[0] = (uint8_t) (0x0A); @@ -962,7 +917,7 @@ mfi_tbolt_build_cdb(struct mfi_softc *sc cdb[1] = (uint8_t) ((lba_lo >> 16) & 0x1F); cdb_len = 6; } - else if ((num_lba <= 0xFFFF) && (lba_lo <= 0xFFFFFFFF)) { + else if (lba_hi == 0 && (num_lba <= 0xFFFF) && (lba_lo <= 0xFFFFFFFF)) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) /* Read 10 or Write 10 */ cdb[0] = (uint8_t) (0x2A); @@ -1152,8 +1107,8 @@ mfi_tbolt_send_frame(struct mfi_softc *s cm->cm_timestamp = time_uptime; mfi_enqueue_busy(cm); } - else { - hdr->cmd_status = 0xff; + else { /* still get interrupts for it */ + hdr->cmd_status = MFI_STAT_INVALID_STATUS; hdr->flags |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE; } @@ -1189,16 +1144,16 @@ mfi_tbolt_send_frame(struct mfi_softc *s return 0; /* This is a polled command, so busy-wait for it to complete. */ - while (hdr->cmd_status == 0xff) { + while (hdr->cmd_status == MFI_STAT_INVALID_STATUS) { DELAY(1000); tm -= 1; if (tm <= 0) - break; + break; } - - if (hdr->cmd_status == 0xff) { + + if (hdr->cmd_status == MFI_STAT_INVALID_STATUS) { device_printf(sc->mfi_dev, "Frame %p timed out " - "command 0x%X\n", hdr, cm->cm_frame->dcmd.opcode); + "command 0x%X\n", hdr, cm->cm_frame->dcmd.opcode); return (ETIMEDOUT); } return 0; @@ -1308,9 +1263,9 @@ static void mfi_process_fw_state_chg_isr mfi_release_command(sc->mfi_aen_cm); sc->mfi_aen_cm = NULL; } - if (sc->map_update_cmd) { - mfi_release_command(sc->map_update_cmd); - sc->map_update_cmd = NULL; + if (sc->mfi_map_sync_cm) { + mfi_release_command(sc->mfi_map_sync_cm); + sc->mfi_map_sync_cm = NULL; } mfi_issue_pending_cmds_again(sc); @@ -1337,3 +1292,171 @@ static void mfi_process_fw_state_chg_isr } mtx_unlock(&sc->mfi_io_lock); } + + +/* + * The ThunderBolt HW has an option for the driver to directly + * access the underlying disks and operate on the RAID. To + * do this there needs to be a capability to keep the RAID controller + * and driver in sync. The FreeBSD driver does not take advantage + * of this feature since it adds a lot of complexity and slows down + * performance. Performance is gained by using the controller's + * cache etc. + * + * Even though this driver doesn't access the disks directly, an + * AEN like command is used to inform the RAID firmware to "sync" + * with all LD's via the MFI_DCMD_LD_MAP_GET_INFO command. This + * command in write mode will return when the RAID firmware has + * detected a change to the RAID state. Examples of this type + * of change are removing a disk. Once the command returns then + * the driver needs to acknowledge this and "sync" all LD's again. + * This repeats until we shutdown. Then we need to cancel this + * pending command. + * + * If this is not done right the RAID firmware will not remove a + * pulled drive and the RAID won't go degraded etc. Effectively, + * stopping any RAID mangement to functions. + * + * Doing another LD sync, requires the use of an event since the + * driver needs to do a mfi_wait_command and can't do that in an + * interrupt thread. + * + * The driver could get the RAID state via the MFI_DCMD_LD_MAP_GET_INFO + * That requires a bunch of structure and it is simplier to just do + * the MFI_DCMD_LD_GET_LIST versus walking the RAID map. + */ + +void +mfi_tbolt_sync_map_info(struct mfi_softc *sc) +{ + int error = 0, i; + struct mfi_command *cmd; + struct mfi_dcmd_frame *dcmd; + uint32_t context = 0; + union mfi_ld_ref *ld_sync; + size_t ld_size; + struct mfi_frame_header *hdr; + struct mfi_command *cm = NULL; + struct mfi_ld_list *list = NULL; + + if (sc->mfi_map_sync_cm != NULL || sc->cm_map_abort) + return; + + mtx_lock(&sc->mfi_io_lock); + error = mfi_dcmd_command(sc, &cm, MFI_DCMD_LD_GET_LIST, + (void **)&list, sizeof(*list)); + if (error) + goto out; + + cm->cm_flags = MFI_CMD_POLLED | MFI_CMD_DATAIN; + if (mfi_wait_command(sc, cm) != 0) { + device_printf(sc->mfi_dev, "Failed to get device listing\n"); + goto out; + } + + hdr = &cm->cm_frame->header; + if (hdr->cmd_status != MFI_STAT_OK) { + device_printf(sc->mfi_dev, "MFI_DCMD_LD_GET_LIST failed %x\n", + hdr->cmd_status); + goto out; + } + + ld_size = sizeof(*ld_sync) * list->ld_count; + mtx_unlock(&sc->mfi_io_lock); + ld_sync = (union mfi_ld_ref *) malloc(ld_size, M_MFIBUF, + M_WAITOK | M_ZERO); + for (i = 0; i < list->ld_count; i++) { + ld_sync[i].ref = list->ld_list[i].ld.ref; + } + + mtx_lock(&sc->mfi_io_lock); + if ((cmd = mfi_dequeue_free(sc)) == NULL) + return; + context = cmd->cm_frame->header.context; + bzero(cmd->cm_frame, sizeof(union mfi_frame)); + cmd->cm_frame->header.context = context; + + dcmd = &cmd->cm_frame->dcmd; + bzero(dcmd->mbox, MFI_MBOX_SIZE); + dcmd->header.cmd = MFI_CMD_DCMD; + dcmd->header.flags = MFI_FRAME_DIR_WRITE; + dcmd->header.timeout = 0; + dcmd->header.data_len = ld_size; + dcmd->header.scsi_status = 0; + dcmd->opcode = MFI_DCMD_LD_MAP_GET_INFO; + cmd->cm_sg = &dcmd->sgl; + cmd->cm_total_frame_size = MFI_DCMD_FRAME_SIZE; + cmd->cm_data = ld_sync; + cmd->cm_private = ld_sync; + + cmd->cm_len = ld_size; + cmd->cm_complete = mfi_sync_map_complete; + sc->mfi_map_sync_cm = cmd; + + cmd->cm_flags = MFI_CMD_DATAOUT; + cmd->cm_frame->dcmd.mbox[0] = list->ld_count; + cmd->cm_frame->dcmd.mbox[1] = MFI_DCMD_MBOX_PEND_FLAG; + + if ((error = mfi_mapcmd(sc, cmd)) != 0) { + device_printf(sc->mfi_dev, "failed to send map sync\n"); + return; + } + +out: + if (list) + free(list, M_MFIBUF); + if (cm) + mfi_release_command(cm); + mtx_unlock(&sc->mfi_io_lock); + + return; +} + + +static void +mfi_sync_map_complete(struct mfi_command *cm) +{ + struct mfi_frame_header *hdr; + struct mfi_softc *sc; + int aborted = 0; + + sc = cm->cm_sc; + mtx_assert(&sc->mfi_io_lock, MA_OWNED); + + hdr = &cm->cm_frame->header; + + if (sc->mfi_map_sync_cm == NULL) + return; + + if (sc->cm_map_abort || + hdr->cmd_status == MFI_STAT_INVALID_STATUS) { + sc->cm_map_abort = 0; + aborted = 1; + } + + free(cm->cm_data, M_MFIBUF); + sc->mfi_map_sync_cm = NULL; + wakeup(&sc->mfi_map_sync_cm); + mfi_release_command(cm); + + /* set it up again so the driver can catch more events */ + if (!aborted) { + mfi_queue_map_sync(sc); + } +} + +static void +mfi_queue_map_sync(struct mfi_softc *sc) +{ + mtx_assert(&sc->mfi_io_lock, MA_OWNED); + taskqueue_enqueue(taskqueue_swi, &sc->mfi_map_sync_task); +} + +void +mfi_handle_map_sync(void *context, int pending) +{ + struct mfi_softc *sc; + + sc = context; + mfi_tbolt_sync_map_info(sc); +} Modified: head/sys/dev/mfi/mfireg.h ============================================================================== --- head/sys/dev/mfi/mfireg.h Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfireg.h Fri May 4 16:00:39 2012 (r235014) @@ -403,6 +403,7 @@ typedef enum { #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152 #define MR_EVT_PD_REMOVED 0x0070 #define MR_EVT_PD_INSERTED 0x005b +#define MR_EVT_LD_CHANGE 0x0051 typedef enum { MR_LD_CACHE_WRITE_BACK = 0x01, Modified: head/sys/dev/mfi/mfivar.h ============================================================================== --- head/sys/dev/mfi/mfivar.h Fri May 4 16:00:22 2012 (r235013) +++ head/sys/dev/mfi/mfivar.h Fri May 4 16:00:39 2012 (r235014) @@ -105,7 +105,6 @@ struct mfi_command { #define MFI_ON_MFIQ_READY (1<<6) #define MFI_ON_MFIQ_BUSY (1<<7) #define MFI_ON_MFIQ_MASK ((1<<5)|(1<<6)|(1<<7)) - int cm_aen_abort; uint8_t retry_for_fw_reset; void (* cm_complete)(struct mfi_command *cm); void *cm_private; @@ -216,9 +215,13 @@ struct mfi_softc { TAILQ_HEAD(,mfi_evt_queue_elm) mfi_evt_queue; struct task mfi_evt_task; + struct task mfi_map_sync_task; TAILQ_HEAD(,mfi_aen) mfi_aen_pids; struct mfi_command *mfi_aen_cm; struct mfi_command *mfi_skinny_cm; + struct mfi_command *mfi_map_sync_cm; + int cm_aen_abort; + int cm_map_abort; uint32_t mfi_aen_triggered; uint32_t mfi_poll_waiting; uint32_t mfi_boot_seq_num; @@ -303,8 +306,6 @@ struct mfi_softc { /* ThunderBolt */ uint32_t mfi_tbolt; uint32_t MFA_enabled; - uint64_t map_id; - struct mfi_command *map_update_cmd; /* Single Reply structure size */ uint16_t reply_size; /* Singler message size. */ @@ -417,7 +418,10 @@ extern int mfi_tbolt_alloc_cmd(struct mf extern int mfi_tbolt_send_frame(struct mfi_softc *sc, struct mfi_command *cm); extern int mfi_tbolt_adp_reset(struct mfi_softc *sc); extern int mfi_tbolt_reset(struct mfi_softc *sc); -extern int mfi_tbolt_sync_map_info(struct mfi_softc *sc); +extern void mfi_tbolt_sync_map_info(struct mfi_softc *sc); +extern void mfi_handle_map_sync(void *context, int pending); +extern int mfi_dcmd_command(struct mfi_softc *, struct mfi_command **, + uint32_t, void **, size_t); #define MFIQ_ADD(sc, qname) \ do { \ From owner-svn-src-head@FreeBSD.ORG Fri May 4 16:22:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC17B1065670; Fri, 4 May 2012 16:22:13 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B651F8FC0A; Fri, 4 May 2012 16:22:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44GMD0e012354; Fri, 4 May 2012 16:22:13 GMT (envelope-from ambrisko@svn.freebsd.org) Received: (from ambrisko@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44GMDAa012350; Fri, 4 May 2012 16:22:13 GMT (envelope-from ambrisko@svn.freebsd.org) Message-Id: <201205041622.q44GMDAa012350@svn.freebsd.org> From: Doug Ambrisko Date: Fri, 4 May 2012 16:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235016 - head/sys/dev/mfi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:22:14 -0000 Author: ambrisko Date: Fri May 4 16:22:13 2012 New Revision: 235016 URL: http://svn.freebsd.org/changeset/base/235016 Log: Some style improvements. Modified: head/sys/dev/mfi/mfi.c head/sys/dev/mfi/mfi_disk.c head/sys/dev/mfi/mfi_tbolt.c Modified: head/sys/dev/mfi/mfi.c ============================================================================== --- head/sys/dev/mfi/mfi.c Fri May 4 16:18:57 2012 (r235015) +++ head/sys/dev/mfi/mfi.c Fri May 4 16:22:13 2012 (r235016) @@ -1319,7 +1319,7 @@ mfi_syspdprobe(struct mfi_softc *sc) /* Add SYSTEM PD's */ error = mfi_dcmd_command(sc, &cm, MFI_DCMD_PD_LIST_QUERY, (void **)&pdlist, sizeof(*pdlist)); - if (error){ + if (error) { device_printf(sc->mfi_dev, "Error while forming SYSTEM PD list\n"); goto out; @@ -1958,6 +1958,7 @@ mfi_add_sys_pd_complete(struct mfi_comma mtx_unlock(&Giant); mtx_lock(&sc->mfi_io_lock); } + static struct mfi_command * mfi_bio_command(struct mfi_softc *sc) { @@ -1965,7 +1966,7 @@ mfi_bio_command(struct mfi_softc *sc) struct mfi_command *cm = NULL; /*reserving two commands to avoid starvation for IOCTL*/ - if (sc->mfi_qstat[MFIQ_FREE].q_length < 2){ + if (sc->mfi_qstat[MFIQ_FREE].q_length < 2) { return (NULL); } if ((bio = mfi_dequeue_bio(sc)) == NULL) { @@ -2694,12 +2695,12 @@ static int mfi_check_for_sscd(struct mfi int error = 0; if ((cm->cm_frame->dcmd.opcode == MFI_DCMD_CFG_ADD) && - (conf_data->ld[0].params.isSSCD == 1)){ + (conf_data->ld[0].params.isSSCD == 1)) { error = 1; } else if (cm->cm_frame->dcmd.opcode == MFI_DCMD_LD_DELETE) { error = mfi_dcmd_command (sc, &ld_cm, MFI_DCMD_LD_GET_INFO, (void **)&ld_info, sizeof(*ld_info)); - if (error){ + if (error) { device_printf(sc->mfi_dev, "Failed to allocate" "MFI_DCMD_LD_GET_INFO %d", error); if (ld_info) @@ -2709,7 +2710,7 @@ static int mfi_check_for_sscd(struct mfi ld_cm->cm_flags = MFI_CMD_DATAIN; ld_cm->cm_frame->dcmd.mbox[0]= cm->cm_frame->dcmd.mbox[0]; ld_cm->cm_frame->header.target_id = cm->cm_frame->dcmd.mbox[0]; - if (mfi_wait_command(sc, ld_cm) != 0){ + if (mfi_wait_command(sc, ld_cm) != 0) { device_printf(sc->mfi_dev, "failed to get log drv\n"); mfi_release_command(ld_cm); free(ld_info, M_MFIBUF); Modified: head/sys/dev/mfi/mfi_disk.c ============================================================================== --- head/sys/dev/mfi/mfi_disk.c Fri May 4 16:18:57 2012 (r235015) +++ head/sys/dev/mfi/mfi_disk.c Fri May 4 16:22:13 2012 (r235016) @@ -256,17 +256,17 @@ mfi_disk_strategy(struct bio *bio) return; } - if (controller->adpreset){ + if (controller->adpreset) { bio->bio_error = EBUSY; return; } - if (controller->hw_crit_error){ + if (controller->hw_crit_error) { bio->bio_error = EBUSY; return; } - if (controller->issuepend_done == 0){ + if (controller->issuepend_done == 0) { bio->bio_error = EBUSY; return; } Modified: head/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:18:57 2012 (r235015) +++ head/sys/dev/mfi/mfi_tbolt.c Fri May 4 16:22:13 2012 (r235016) @@ -141,11 +141,12 @@ mfi_tbolt_issue_cmd_ppc(struct mfi_softc MFI_WRITE4(sc, MFI_IQPH, (uint32_t)((uint64_t)bus_add >> 32)); } -/** +/* * mfi_tbolt_adp_reset - For controller reset * @regs: MFI register set */ -int mfi_tbolt_adp_reset(struct mfi_softc *sc) +int +mfi_tbolt_adp_reset(struct mfi_softc *sc) { int retry = 0, i = 0; int HostDiag; @@ -193,12 +194,10 @@ int mfi_tbolt_adp_reset(struct mfi_softc } /* - ******************************************************************************************* - * Description: - * This routine initialize Thunderbolt specific device information - ******************************************************************************************* + * This routine initialize Thunderbolt specific device information */ -void mfi_tbolt_init_globals(struct mfi_softc *sc) +void +mfi_tbolt_init_globals(struct mfi_softc *sc) { /* Initialize single reply size and Message size */ sc->reply_size = MEGASAS_THUNDERBOLT_REPLY_SIZE; @@ -240,16 +239,12 @@ void mfi_tbolt_init_globals(struct mfi_s } /* - **************************************************************************** - * Description: - * This function calculates the memory requirement for Thunderbolt - * controller - * Return Value: - * Total required memory in bytes - **************************************************************************** + * This function calculates the memory requirement for Thunderbolt + * controller, returns the total required memory in bytes */ -uint32_t mfi_tbolt_get_memory_requirement(struct mfi_softc *sc) +uint32_t +mfi_tbolt_get_memory_requirement(struct mfi_softc *sc) { uint32_t size; size = MEGASAS_THUNDERBOLT_MSG_ALLIGNMENT; /* for Alignment */ @@ -261,7 +256,6 @@ uint32_t mfi_tbolt_get_memory_requiremen } /* - **************************************************************************** * Description: * This function will prepare message pools for the Thunderbolt controller * Arguments: @@ -270,9 +264,9 @@ uint32_t mfi_tbolt_get_memory_requiremen * Return Value: * TRUE if successful * FALSE if failed - **************************************************************************** */ -int mfi_tbolt_init_desc_pool(struct mfi_softc *sc, uint8_t* mem_location, +int +mfi_tbolt_init_desc_pool(struct mfi_softc *sc, uint8_t* mem_location, uint32_t tbolt_contg_length) { uint32_t offset = 0; @@ -329,10 +323,7 @@ int mfi_tbolt_init_desc_pool(struct mfi_ } /* - **************************************************************************** - * Description: - * This routine prepare and issue INIT2 frame to the Firmware - **************************************************************************** + * This routine prepare and issue INIT2 frame to the Firmware */ int @@ -443,7 +434,8 @@ mfi_tbolt_init_MFI_queue(struct mfi_soft } -int mfi_tbolt_alloc_cmd(struct mfi_softc *sc) +int +mfi_tbolt_alloc_cmd(struct mfi_softc *sc) { struct mfi_cmd_tbolt *cmd; bus_addr_t io_req_base_phys; @@ -516,7 +508,8 @@ int mfi_tbolt_alloc_cmd(struct mfi_softc return 0; } -int mfi_tbolt_reset(struct mfi_softc *sc) +int +mfi_tbolt_reset(struct mfi_softc *sc) { uint32_t fw_state; @@ -551,7 +544,8 @@ int mfi_tbolt_reset(struct mfi_softc *sc /* * mfi_intr_tbolt - isr entry point */ -void mfi_intr_tbolt(void *arg) +void +mfi_intr_tbolt(void *arg) { struct mfi_softc *sc = (struct mfi_softc *)arg; @@ -569,7 +563,7 @@ void mfi_intr_tbolt(void *arg) return; } -/** +/* * map_cmd_status - Maps FW cmd status to OS cmd status * @cmd : Pointer to cmd * @status : status of cmd returned by FW @@ -582,7 +576,6 @@ map_tbolt_cmd_status(struct mfi_command { switch (status) { - case MFI_STAT_OK: mfi_cmd->cm_frame->header.cmd_status = 0; mfi_cmd->cm_frame->dcmd.header.cmd_status = 0; @@ -615,7 +608,7 @@ map_tbolt_cmd_status(struct mfi_command } } -/** +/* * mfi_tbolt_return_cmd - Return a cmd to free command pool * @instance: Adapter soft state * @cmd: Command packet to be returned to free command pool @@ -718,15 +711,15 @@ mfi_tbolt_complete_cmd(struct mfi_softc return; } -/** +/* * mfi_get_cmd - Get a command from the free pool * @instance: Adapter soft state * * Returns a free command from the pool */ -struct mfi_cmd_tbolt *mfi_tbolt_get_cmd(struct mfi_softc - *sc) +struct mfi_cmd_tbolt * +mfi_tbolt_get_cmd(struct mfi_softc *sc) { struct mfi_cmd_tbolt *cmd = NULL; @@ -831,7 +824,8 @@ mfi_tbolt_build_ldio(struct mfi_softc *s * MFI_SECTOR_LEN; } -int mfi_tbolt_is_ldio(struct mfi_command *mfi_cmd) +int +mfi_tbolt_is_ldio(struct mfi_command *mfi_cmd) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_READ || mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) @@ -841,7 +835,8 @@ int mfi_tbolt_is_ldio(struct mfi_command } int -mfi_tbolt_build_io(struct mfi_softc *sc, struct mfi_command *mfi_cmd, struct mfi_cmd_tbolt *cmd) +mfi_tbolt_build_io(struct mfi_softc *sc, struct mfi_command *mfi_cmd, + struct mfi_cmd_tbolt *cmd) { uint32_t device_id; uint32_t sge_count; @@ -930,8 +925,7 @@ mfi_tbolt_build_cdb(struct mfi_softc *sc cdb[3] = (uint8_t) (lba_lo >> 16); cdb[2] = (uint8_t) (lba_lo >> 24); cdb_len = 10; - } - else if ((num_lba > 0xFFFF) && (lba_hi == 0)) { + } else if ((num_lba > 0xFFFF) && (lba_hi == 0)) { if (mfi_cmd->cm_frame->header.cmd == MFI_CMD_LD_WRITE) /* Read 12 or Write 12 */ cdb[0] = (uint8_t) (0xAA); @@ -1150,7 +1144,7 @@ mfi_tbolt_send_frame(struct mfi_softc *s if (tm <= 0) break; } - + if (hdr->cmd_status == MFI_STAT_INVALID_STATUS) { device_printf(sc->mfi_dev, "Frame %p timed out " "command 0x%X\n", hdr, cm->cm_frame->dcmd.opcode); @@ -1159,7 +1153,8 @@ mfi_tbolt_send_frame(struct mfi_softc *s return 0; } -static void mfi_issue_pending_cmds_again (struct mfi_softc *sc) +static void +mfi_issue_pending_cmds_again (struct mfi_softc *sc) { struct mfi_command *cm, *tmp; @@ -1204,7 +1199,8 @@ static void mfi_issue_pending_cmds_again mfi_startio(sc); } -static void mfi_kill_hba (struct mfi_softc *sc) +static void +mfi_kill_hba (struct mfi_softc *sc) { if (sc->mfi_flags & MFI_FLAGS_TBOLT) MFI_WRITE4 (sc, 0x00,MFI_STOP_ADP); @@ -1212,7 +1208,8 @@ static void mfi_kill_hba (struct mfi_sof MFI_WRITE4 (sc, MFI_IDB,MFI_STOP_ADP); } -static void mfi_process_fw_state_chg_isr(void *arg) +static void +mfi_process_fw_state_chg_isr(void *arg) { struct mfi_softc *sc= (struct mfi_softc *)arg; struct mfi_cmd_tbolt *cmd; @@ -1296,7 +1293,7 @@ static void mfi_process_fw_state_chg_isr /* * The ThunderBolt HW has an option for the driver to directly - * access the underlying disks and operate on the RAID. To + * access the underlying disks and operate on the RAID. To * do this there needs to be a capability to keep the RAID controller * and driver in sync. The FreeBSD driver does not take advantage * of this feature since it adds a lot of complexity and slows down From owner-svn-src-head@FreeBSD.ORG Fri May 4 16:40:11 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13D431065672; Fri, 4 May 2012 16:40:11 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id BC2568FC1A; Fri, 4 May 2012 16:40:10 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so4461374pbb.13 for ; Fri, 04 May 2012 09:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=OSsDv0j8rMYgL8lw65iG2OJnyTQeVF8vetEsuC0v84c=; b=osciytzUpHCKkr5v/CZF8z/eWKjG4c2bX2VvcIcWGg7sYGIi3Xs+nuFlYI5JZ2xSPa 3yoqu6pv52NsruB7I+7pkclag9vAO+Ozj/aQtCLp+LW+U4449VEleQ3EhAH06PNaeFRR cNTVyqc/uguTjCnFceEeq9ftu+RER09qlpJZ1XxYCl3oYn5iw1NyJVxeBc5cF7SpOgZT r+jWtyUjBKgqzF71HkAwoZMoIQNj0zHKXCco9fVtCq0Ry1mzARQq/0hpypWjHKM0fK/H 3ea8SerdPDTnoBuU9m9jwqm/9CzUYqq4xoilMgZ3PhUcgJwTYAznC/hGA1uGsXqunB8J wZYA== Received: by 10.68.233.136 with SMTP id tw8mr2127621pbc.71.1336149224972; Fri, 04 May 2012 09:33:44 -0700 (PDT) Received: from [10.170.185.186] (mobile-166-147-081-047.mycingular.net. [166.147.81.47]) by mx.google.com with ESMTPS id q5sm9058810pbp.28.2012.05.04.09.33.43 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 09:33:43 -0700 (PDT) References: <201205041531.q44FVaYF010236@svn.freebsd.org> In-Reply-To: <201205041531.q44FVaYF010236@svn.freebsd.org> Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: X-Mailer: iPhone Mail (9B179) From: Garrett Cooper Date: Fri, 4 May 2012 09:33:38 -0700 To: Josh Paetzel Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "kmoore@freebsd.org" Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 16:40:11 -0000 On May 4, 2012, at 8:31 AM, Josh Paetzel wrote: > Author: jpaetzel > Date: Fri May 4 15:31:35 2012 > New Revision: 235005 > URL: http://svn.freebsd.org/changeset/base/235005 >=20 > Log: > Use a unique zpool name during install, in the case of having another > PC-BSD / FreeBSD zpool on the system for another install. >=20 > Submitted by: kmoore > Obtained from: PC-BSD > MFC after: 3 days > Sponsored by: iXsystems >=20 > Modified: > head/usr.sbin/pc-sysinstall/backend/functions.sh >=20 > Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > --- head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:27:1= 8 2012 (r235004) > +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:31:3= 5 2012 (r235005) > @@ -216,7 +216,7 @@ fetch_file() >=20 > fetch -s "${FETCHFILE}" >${SIZEFILE} > SIZE=3D"`cat ${SIZEFILE}`" > - SIZE=3D"`expr ${SIZE} / 1024`" > + SIZE=3D$((SIZE/1024)) Bug; should be '$SIZE/' > echo "FETCH: ${FETCHFILE}" > echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} >=20 > @@ -276,11 +276,22 @@ get_zpool_name() > else > # Need to generate a zpool name for this device > NUM=3D`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` > - NEWNAME=3D"${BASENAME}${NUM}" > + > + # Is it used in another zpool? > + while > + z=3D1 > + do while : do Is better. > + NEWNAME=3D"${BASENAME}${NUM}" > + zpool import | grep -q "${NEWNAME}" > + if [ $? -ne 0 ] ; then break ; fi Please decompress the conditional. > + NUM=3D$((NUM+1)) Another bug (see above). Thanks, -Garrett= From owner-svn-src-head@FreeBSD.ORG Fri May 4 17:18:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 51C311065672; Fri, 4 May 2012 17:18:03 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 23F0C8FC0C; Fri, 4 May 2012 17:18:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44HI26T014327; Fri, 4 May 2012 17:18:02 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44HI2lT014325; Fri, 4 May 2012 17:18:02 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205041718.q44HI2lT014325@svn.freebsd.org> From: Michael Tuexen Date: Fri, 4 May 2012 17:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235021 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 17:18:03 -0000 Author: tuexen Date: Fri May 4 17:18:02 2012 New Revision: 235021 URL: http://svn.freebsd.org/changeset/base/235021 Log: Add support for the SCTP_ENABLE_STREAM_RESET socket option to getsockopt(). This improves the support of RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Fri May 4 17:12:31 2012 (r235020) +++ head/sys/netinet/sctp_usrreq.c Fri May 4 17:18:02 2012 (r235021) @@ -3296,6 +3296,33 @@ flags_out: } break; } + case SCTP_ENABLE_STREAM_RESET: + { + struct sctp_assoc_value *av; + + SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, *optsize); + SCTP_FIND_STCB(inp, stcb, av->assoc_id); + + if (stcb) { + av->assoc_value = (uint32_t) stcb->asoc.local_strreset_support; + SCTP_TCB_UNLOCK(stcb); + } else { + if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) || + (av->assoc_id == SCTP_FUTURE_ASSOC)) { + SCTP_INP_RLOCK(inp); + av->assoc_value = (uint32_t) inp->local_strreset_support; + SCTP_INP_RUNLOCK(inp); + } else { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); + error = EINVAL; + } + } + if (error == 0) { + *optsize = sizeof(struct sctp_assoc_value); + } + break; + } default: SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOPROTOOPT); error = ENOPROTOOPT; @@ -4096,7 +4123,6 @@ sctp_setopt(struct socket *so, int optna case SCTP_ENABLE_STREAM_RESET: { struct sctp_assoc_value *av; - uint8_t set_value = 0; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); if (av->assoc_value & (~SCTP_ENABLE_VALUE_MASK)) { @@ -4104,10 +4130,9 @@ sctp_setopt(struct socket *so, int optna error = EINVAL; break; } - set_value = av->assoc_value & SCTP_ENABLE_VALUE_MASK; SCTP_FIND_STCB(inp, stcb, av->assoc_id); if (stcb) { - stcb->asoc.local_strreset_support = set_value; + stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value; SCTP_TCB_UNLOCK(stcb); } else { if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || @@ -4115,7 +4140,7 @@ sctp_setopt(struct socket *so, int optna (av->assoc_id == SCTP_FUTURE_ASSOC) || (av->assoc_id == SCTP_ALL_ASSOC)) { SCTP_INP_WLOCK(inp); - inp->local_strreset_support = set_value; + inp->local_strreset_support = (uint8_t) av->assoc_value; SCTP_INP_WUNLOCK(inp); } if ((av->assoc_id == SCTP_CURRENT_ASSOC) || @@ -4123,7 +4148,7 @@ sctp_setopt(struct socket *so, int optna SCTP_INP_RLOCK(inp); LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { SCTP_TCB_LOCK(stcb); - stcb->asoc.local_strreset_support = set_value; + stcb->asoc.local_strreset_support = (uint8_t) av->assoc_value; SCTP_TCB_UNLOCK(stcb); } SCTP_INP_RUNLOCK(inp); From owner-svn-src-head@FreeBSD.ORG Fri May 4 18:22:04 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AD30C1065670; Fri, 4 May 2012 18:22:04 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8B3DF8FC0A; Fri, 4 May 2012 18:22:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q44IM43i082553; Fri, 4 May 2012 18:22:04 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q44IM4ET082552; Fri, 4 May 2012 18:22:04 GMT (envelope-from bapt@FreeBSD.org) X-Authentication-Warning: freefall.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f Date: Fri, 4 May 2012 20:22:00 +0200 From: Baptiste Daroussin To: Garrett Cooper Message-ID: <20120504182200.GD1604@azathoth.lan> References: <201205041531.q44FVaYF010236@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bajzpZikUji1w+G9" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Josh Paetzel , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "kmoore@freebsd.org" Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:22:04 -0000 --bajzpZikUji1w+G9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 04, 2012 at 09:33:38AM -0700, Garrett Cooper wrote: > On May 4, 2012, at 8:31 AM, Josh Paetzel wrote: >=20 > > Author: jpaetzel > > Date: Fri May 4 15:31:35 2012 > > New Revision: 235005 > > URL: http://svn.freebsd.org/changeset/base/235005 > >=20 > > Log: > > Use a unique zpool name during install, in the case of having another > > PC-BSD / FreeBSD zpool on the system for another install. > >=20 > > Submitted by: kmoore > > Obtained from: PC-BSD > > MFC after: 3 days > > Sponsored by: iXsystems > >=20 > > Modified: > > head/usr.sbin/pc-sysinstall/backend/functions.sh > >=20 > > Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:2= 7:18 2012 (r235004) > > +++ head/usr.sbin/pc-sysinstall/backend/functions.sh Fri May 4 15:3= 1:35 2012 (r235005) > > @@ -216,7 +216,7 @@ fetch_file() > >=20 > > fetch -s "${FETCHFILE}" >${SIZEFILE} > > SIZE=3D"`cat ${SIZEFILE}`" > > - SIZE=3D"`expr ${SIZE} / 1024`" > > + SIZE=3D$((SIZE/1024)) >=20 > Bug; should be '$SIZE/' No this is perfectly valid >=20 > > echo "FETCH: ${FETCHFILE}" > > echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} > >=20 > > @@ -276,11 +276,22 @@ get_zpool_name() > > else > > # Need to generate a zpool name for this device > > NUM=3D`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` > > - NEWNAME=3D"${BASENAME}${NUM}" > > + > > + # Is it used in another zpool? > > + while > > + z=3D1 > > + do >=20 > while : > do >=20 > Is better. >=20 > > + NEWNAME=3D"${BASENAME}${NUM}" > > + zpool import | grep -q "${NEWNAME}" > > + if [ $? -ne 0 ] ; then break ; fi >=20 > Please decompress the conditional. or=20 zpool import | grep -q "${NEWNAME}" && break btw this is potentially buggy if there is a zpool named: a${NEWNAME}b for example zpool import | grep -qw "${NEWNAME}" && break should be perhaps better >=20 > > + NUM=3D$((NUM+1)) >=20 > Another bug (see above). >=20 > Thanks, > -Garrett --bajzpZikUji1w+G9 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk+kHkgACgkQ8kTtMUmk6EwriACfTQPvFz9qT2HdxyQZUj3FA7zX N5oAoISZGfdLeNb1eUn41wHOke1rrjRG =oi4X -----END PGP SIGNATURE----- --bajzpZikUji1w+G9-- From owner-svn-src-head@FreeBSD.ORG Fri May 4 18:24:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5AACA106566C; Fri, 4 May 2012 18:24:39 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 44DAB8FC08; Fri, 4 May 2012 18:24:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44IOdkF016993; Fri, 4 May 2012 18:24:39 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44IOdjw016990; Fri, 4 May 2012 18:24:39 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201205041824.q44IOdjw016990@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 4 May 2012 18:24:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235024 - in head: share/man/man4 sys/dev/acpica X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:24:39 -0000 Author: jkim Date: Fri May 4 18:24:38 2012 New Revision: 235024 URL: http://svn.freebsd.org/changeset/base/235024 Log: Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may list CPUs in different orders, especially for disabled logical cores. Now we match ACPI IDs from the MADT with Processor objects, strictly order CPUs accordingly, and ignore disabled cores. This prevents us from executing methods for other CPUs, e. g., _PSS for disabled logical core, which may not exist. Unfortunately, it is known that there are a few systems with buggy BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To work around these problems Modified: head/share/man/man4/acpi.4 head/sys/dev/acpica/acpi.c Modified: head/share/man/man4/acpi.4 ============================================================================== --- head/share/man/man4/acpi.4 Fri May 4 18:23:03 2012 (r235023) +++ head/share/man/man4/acpi.4 Fri May 4 18:24:38 2012 (r235024) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 22, 2012 +.Dd May 4, 2012 .Dt ACPI 4 .Os .Sh NAME @@ -198,6 +198,11 @@ entry for access after boot. Enables loading of a custom ACPI DSDT. .It Va acpi_dsdt_name Name of the DSDT table to load, if loading is enabled. +.It Va debug.acpi.cpu_unordered +Do not use the MADT to match ACPI processor objects to CPUs. +This is needed on a few systems with a buggy BIOS that does not use +consistent processor IDs. +Default is 0 (disabled). .It Va debug.acpi.disabled Selectively disables portions of ACPI for debugging purposes. .It Va debug.acpi.interpreter_slack Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Fri May 4 18:23:03 2012 (r235023) +++ head/sys/dev/acpica/acpi.c Fri May 4 18:24:38 2012 (r235024) @@ -289,6 +289,13 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, reset_ &acpi_reset_clock, 1, "Reset system clock while resuming."); #endif +/* Allow users to ignore processor orders in MADT. */ +static int acpi_cpu_unordered; +TUNABLE_INT("debug.acpi.cpu_unordered", &acpi_cpu_unordered); +SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, + &acpi_cpu_unordered, 0, + "Do not use the MADT to match ACPI processor objects to CPUs."); + /* Allow users to override quirks. */ TUNABLE_INT("debug.acpi.quirks", &acpi_quirks); @@ -1856,11 +1863,15 @@ static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) { struct acpi_prw_data prw; + ACPI_BUFFER buf; + ACPI_OBJECT obj; ACPI_OBJECT_TYPE type; ACPI_HANDLE h; + struct pcpu *pc; device_t bus, child; char *handle_str; - int order; + u_int cpuid; + int order, unit; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -1898,6 +1909,31 @@ acpi_probe_child(ACPI_HANDLE handle, UIN case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: case ACPI_TYPE_POWER: + unit = -1; + if (type == ACPI_TYPE_PROCESSOR && acpi_cpu_unordered == 0) { + ACPI_STATUS s; + buf.Pointer = &obj; + buf.Length = sizeof(obj); + s = AcpiEvaluateObject(handle, NULL, NULL, &buf); + if (ACPI_SUCCESS(s)) { + CPU_FOREACH(cpuid) { + pc = pcpu_find(cpuid); + if (pc->pc_acpi_id == obj.Processor.ProcId) { + unit = cpuid; + if (bootverbose) + printf("ACPI: %s (ACPI ID %u) -> cpu%d\n", + handle_str, obj.Processor.ProcId, unit); + break; + } + } + if (unit == -1) { + if (bootverbose) + printf("ACPI: %s (ACPI ID %u) ignored\n", + handle_str, obj.Processor.ProcId); + break; + } + } + } /* * Create a placeholder device for this node. Sort the * placeholder so that the probe/attach passes will run @@ -1908,7 +1944,7 @@ acpi_probe_child(ACPI_HANDLE handle, UIN ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "scanning '%s'\n", handle_str)); order = level * 10 + ACPI_DEV_BASE_ORDER; acpi_probe_order(handle, &order); - child = BUS_ADD_CHILD(bus, order, NULL, -1); + child = BUS_ADD_CHILD(bus, order, NULL, unit); if (child == NULL) break; From owner-svn-src-head@FreeBSD.ORG Fri May 4 18:29:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 544A6106564A; Fri, 4 May 2012 18:29:36 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CAEF88FC0C; Fri, 4 May 2012 18:29:35 +0000 (UTC) Message-ID: <4FA4200F.6010300@FreeBSD.org> Date: Fri, 04 May 2012 14:29:35 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120502 Thunderbird/12.0.1 MIME-Version: 1.0 To: Jung-uk Kim References: <201205041824.q44IOdjw016990@svn.freebsd.org> In-Reply-To: <201205041824.q44IOdjw016990@svn.freebsd.org> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r235024 - in head: share/man/man4 sys/dev/acpica X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:29:36 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2012-05-04 14:24:39 -0400, Jung-uk Kim wrote: > Author: jkim Date: Fri May 4 18:24:38 2012 New Revision: 235024 > URL: http://svn.freebsd.org/changeset/base/235024 > > Log: Use MADT to match ACPI Processor objects to CPUs. MADT and > DSDT/SSDTs may list CPUs in different orders, especially for > disabled logical cores. Now we match ACPI IDs from the MADT with > Processor objects, strictly order CPUs accordingly, and ignore > disabled cores. This prevents us from executing methods for other > CPUs, e. g., _PSS for disabled logical core, which may not exist. > Unfortunately, it is known that there are a few systems with buggy > BIOSes that do not have unique ACPI IDs for MADT and Processor > objects. To work around these problems , 'debug.acpi.cpu_unordered' tunable is added. Set this to non-zero value to restore the old behavior. Sorry, the commit message was incomplete. How do I fix it? Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+kIA8ACgkQmlay1b9qnVM8dQCg1D1cQhd0zLkTD3/uWzFOSI4u Ph4AoL1QzIgRmp4JduHpJaPlP3i64s84 =bXd0 -----END PGP SIGNATURE----- From owner-svn-src-head@FreeBSD.ORG Fri May 4 18:54:52 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B709106566B; Fri, 4 May 2012 18:54:52 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C8038FC08; Fri, 4 May 2012 18:54:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44IsqsD018090; Fri, 4 May 2012 18:54:52 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44IsqJ8018087; Fri, 4 May 2012 18:54:52 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201205041854.q44IsqJ8018087@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 4 May 2012 18:54:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235029 - in head: share/man/man4 sys/dev/acpica X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:54:52 -0000 Author: jkim Date: Fri May 4 18:54:51 2012 New Revision: 235029 URL: http://svn.freebsd.org/changeset/base/235029 Log: Complete commit message for r235024: Use MADT to match ACPI Processor objects to CPUs. MADT and DSDT/SSDTs may list CPUs in different orders, especially for disabled logical cores. Now we match ACPI IDs from the MADT with Processor objects, strictly order CPUs accordingly, and ignore disabled cores. This prevents us from executing methods for other CPUs, e. g., _PSS for disabled logical core, which may not exist. Unfortunately, it is known that there are a few systems with buggy BIOSes that do not have unique ACPI IDs for MADT and Processor objects. To work around these problems, 'debug.acpi.cpu_unordered' tunable is added. Set this to a non-zero value to restore the old behavior. Many thanks to jhb for pointing me to the right direction and the manual page change. Reported by: Harris, James R (james dot r dot harris at intel dot com) Tested by: Harris, James R (james dot r dot harris at intel dot com) Reviewed by: jhb MFC after: 1 month Modified: head/share/man/man4/acpi.4 head/sys/dev/acpica/acpi.c Modified: head/share/man/man4/acpi.4 ============================================================================== --- head/share/man/man4/acpi.4 Fri May 4 18:36:00 2012 (r235028) +++ head/share/man/man4/acpi.4 Fri May 4 18:54:51 2012 (r235029) @@ -199,7 +199,7 @@ Enables loading of a custom ACPI DSDT. .It Va acpi_dsdt_name Name of the DSDT table to load, if loading is enabled. .It Va debug.acpi.cpu_unordered -Do not use the MADT to match ACPI processor objects to CPUs. +Do not use the MADT to match ACPI Processor objects to CPUs. This is needed on a few systems with a buggy BIOS that does not use consistent processor IDs. Default is 0 (disabled). Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Fri May 4 18:36:00 2012 (r235028) +++ head/sys/dev/acpica/acpi.c Fri May 4 18:54:51 2012 (r235029) @@ -294,7 +294,7 @@ static int acpi_cpu_unordered; TUNABLE_INT("debug.acpi.cpu_unordered", &acpi_cpu_unordered); SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, &acpi_cpu_unordered, 0, - "Do not use the MADT to match ACPI processor objects to CPUs."); + "Do not use the MADT to match ACPI Processor objects to CPUs."); /* Allow users to override quirks. */ TUNABLE_INT("debug.acpi.quirks", &acpi_quirks); From owner-svn-src-head@FreeBSD.ORG Fri May 4 18:59:29 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CDE53106566B; Fri, 4 May 2012 18:59:29 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id 7DACC8FC16; Fri, 4 May 2012 18:59:29 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id C9B12A24; Fri, 4 May 2012 20:59:27 +0200 (CEST) Date: Fri, 4 May 2012 20:57:46 +0200 From: Pawel Jakub Dawidek To: Eitan Adler Message-ID: <20120504185743.GA1397@garage.freebsd.pl> References: <201203242110.q2OLAJSZ049045@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gKMricLos+KVdGMg" Content-Disposition: inline In-Reply-To: <201203242110.q2OLAJSZ049045@svn.freebsd.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r233435 - head/etc/mtree X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 18:59:29 -0000 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 24, 2012 at 09:10:19PM +0000, Eitan Adler wrote: > Author: eadler > Date: Sat Mar 24 21:10:19 2012 > New Revision: 233435 > URL: http://svn.freebsd.org/changeset/base/233435 >=20 > Log: > Fix build by adding new directory to mtree in r233429 > =20 > Submitted by: flo > Approved by: cperciva > MFC after: 1 week >=20 > Modified: > head/etc/mtree/BSD.usr.dist >=20 > Modified: head/etc/mtree/BSD.usr.dist > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/etc/mtree/BSD.usr.dist Sat Mar 24 19:59:14 2012 (r233434) > +++ head/etc/mtree/BSD.usr.dist Sat Mar 24 21:10:19 2012 (r233435) > @@ -209,6 +209,8 @@ > .. > bootforth > .. > + csh > + .. > cvs You need to use only spaces in this file for indentation just like in all the other lines. That's a shame it was merged into 7, 8 and 9. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --gKMricLos+KVdGMg Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk+kJqYACgkQForvXbEpPzTVGwCfelXiwNt0tO5qyicbwKLj2s2c SGwAniXuZPotFQwUMzIHeHHtXmu14vm1 =OPaQ -----END PGP SIGNATURE----- --gKMricLos+KVdGMg-- From owner-svn-src-head@FreeBSD.ORG Fri May 4 19:49:24 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A2100106564A; Fri, 4 May 2012 19:49:24 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8D8C38FC0A; Fri, 4 May 2012 19:49:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44JnOmk020197; Fri, 4 May 2012 19:49:24 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44JnO2L020195; Fri, 4 May 2012 19:49:24 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201205041949.q44JnO2L020195@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 4 May 2012 19:49:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235033 - head/sbin/geom/class/part X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 19:49:24 -0000 Author: ae Date: Fri May 4 19:49:24 2012 New Revision: 235033 URL: http://svn.freebsd.org/changeset/base/235033 Log: Don't ignore start offset value when user specifies it together with alignment. PR: bin/167567 Tested by: Warren Block MFC after: 1 week Modified: head/sbin/geom/class/part/geom_part.c Modified: head/sbin/geom/class/part/geom_part.c ============================================================================== --- head/sbin/geom/class/part/geom_part.c Fri May 4 19:44:58 2012 (r235032) +++ head/sbin/geom/class/part/geom_part.c Fri May 4 19:49:24 2012 (r235033) @@ -507,6 +507,8 @@ gpart_autofill(struct gctl_req *req) grade = ~0ULL; a_first = ALIGNUP(first + offset, alignment); last = ALIGNDOWN(last + offset, alignment); + if (a_first < start) + a_first = start; while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); lba = (off_t)strtoimax(s, NULL, 0); @@ -536,7 +538,8 @@ gpart_autofill(struct gctl_req *req) s = find_provcfg(pp, "end"); first = (off_t)strtoimax(s, NULL, 0) + 1; - a_first = ALIGNUP(first + offset, alignment); + if (first > a_first) + a_first = ALIGNUP(first + offset, alignment); } if (a_first <= last) { /* Free space [first-last] */ From owner-svn-src-head@FreeBSD.ORG Fri May 4 20:15:02 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35]) by hub.freebsd.org (Postfix) with ESMTP id A54481065675; Fri, 4 May 2012 20:15:02 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from [127.0.0.1] (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx2.freebsd.org (Postfix) with ESMTP id B424C14DB89; Fri, 4 May 2012 20:15:00 +0000 (UTC) Message-ID: <4FA438C4.3080701@FreeBSD.org> Date: Fri, 04 May 2012 13:15:00 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 To: Baptiste Daroussin References: <201205041531.q44FVaYF010236@svn.freebsd.org> <20120504182200.GD1604@azathoth.lan> In-Reply-To: <20120504182200.GD1604@azathoth.lan> X-Enigmail-Version: 1.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "src-committers@freebsd.org" , Garrett Cooper , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" , "kmoore@freebsd.org" , Josh Paetzel Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 20:15:02 -0000 On 05/04/2012 11:22 AM, Baptiste Daroussin wrote: >>> > > fetch -s "${FETCHFILE}" >${SIZEFILE} >>> > > SIZE="`cat ${SIZEFILE}`" >>> > > - SIZE="`expr ${SIZE} / 1024`" >>> > > + SIZE=$((SIZE/1024)) >> > >> > Bug; should be '$SIZE/' > No this is perfectly valid Yes, that works, but it's not our usual style. However, the point is moot as that whole block should be reduced down to: SIZE=$(( `fetch -s "${FETCHFILE}"` / 1024 )) If SIZEFILE is needed elsewhere that's a different matter, but as it is that's a hot mess. From owner-svn-src-head@FreeBSD.ORG Fri May 4 20:31:27 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9CA92106564A; Fri, 4 May 2012 20:31:27 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8812B8FC0C; Fri, 4 May 2012 20:31:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44KVRrd021549; Fri, 4 May 2012 20:31:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44KVRZr021547; Fri, 4 May 2012 20:31:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201205042031.q44KVRZr021547@svn.freebsd.org> From: Adrian Chadd Date: Fri, 4 May 2012 20:31:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235034 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 20:31:27 -0000 Author: adrian Date: Fri May 4 20:31:27 2012 New Revision: 235034 URL: http://svn.freebsd.org/changeset/base/235034 Log: Fix a couple of sc_ac2q[] mappings that were using the TID, not the AC. PR: kern/167588 Modified: head/sys/dev/ath/if_ath_tx.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Fri May 4 19:49:24 2012 (r235033) +++ head/sys/dev/ath/if_ath_tx.c Fri May 4 20:31:27 2012 (r235034) @@ -4307,9 +4307,9 @@ ath_addba_request(struct ieee80211_node * it'll be "after" the left edge of the BAW and thus it'll * fall within it. */ - ATH_TXQ_LOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); ath_tx_tid_pause(sc, atid); - ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n", @@ -4395,9 +4395,9 @@ ath_addba_stop(struct ieee80211_node *ni DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__); /* Pause TID traffic early, so there aren't any races */ - ATH_TXQ_LOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); ath_tx_tid_pause(sc, atid); - ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->tid]); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); /* There's no need to hold the TXQ lock here */ sc->sc_addba_stop(ni, tap); From owner-svn-src-head@FreeBSD.ORG Fri May 4 21:00:33 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22DD2106564A; Fri, 4 May 2012 21:00:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E55D8FC1A; Fri, 4 May 2012 21:00:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44L0Wog022597; Fri, 4 May 2012 21:00:32 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44L0WZJ022595; Fri, 4 May 2012 21:00:32 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205042100.q44L0WZJ022595@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 21:00:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235036 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:00:33 -0000 Author: delphij Date: Fri May 4 21:00:32 2012 New Revision: 235036 URL: http://svn.freebsd.org/changeset/base/235036 Log: Add ToS definitions for DiffServ Codepoints as per RFC2474. Obtained from: OpenBSD MFC after: 2 weeks Modified: head/sys/netinet/ip.h Modified: head/sys/netinet/ip.h ============================================================================== --- head/sys/netinet/ip.h Fri May 4 20:45:53 2012 (r235035) +++ head/sys/netinet/ip.h Fri May 4 21:00:32 2012 (r235036) @@ -92,6 +92,31 @@ struct ip { #define IPTOS_PREC_ROUTINE 0x00 /* + * Definitions for DiffServ Codepoints as per RFC2474 + */ +#define IPTOS_DSCP_CS0 0x00 +#define IPTOS_DSCP_CS1 0x20 +#define IPTOS_DSCP_AF11 0x28 +#define IPTOS_DSCP_AF12 0x30 +#define IPTOS_DSCP_AF13 0x38 +#define IPTOS_DSCP_CS2 0x40 +#define IPTOS_DSCP_AF21 0x48 +#define IPTOS_DSCP_AF22 0x50 +#define IPTOS_DSCP_AF23 0x58 +#define IPTOS_DSCP_CS3 0x60 +#define IPTOS_DSCP_AF31 0x68 +#define IPTOS_DSCP_AF32 0x70 +#define IPTOS_DSCP_AF33 0x78 +#define IPTOS_DSCP_CS4 0x80 +#define IPTOS_DSCP_AF41 0x88 +#define IPTOS_DSCP_AF42 0x90 +#define IPTOS_DSCP_AF43 0x98 +#define IPTOS_DSCP_CS5 0xa0 +#define IPTOS_DSCP_EF 0xb8 +#define IPTOS_DSCP_CS6 0xc0 +#define IPTOS_DSCP_CS7 0xe0 + +/* * ECN (Explicit Congestion Notification) codepoints in RFC3168 mapped to the * lower 2 bits of the TOS field. */ From owner-svn-src-head@FreeBSD.ORG Fri May 4 21:03:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD6E8106564A; Fri, 4 May 2012 21:03:39 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7C918FC0C; Fri, 4 May 2012 21:03:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44L3dNg022750; Fri, 4 May 2012 21:03:39 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44L3dgo022747; Fri, 4 May 2012 21:03:39 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205042103.q44L3dgo022747@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 21:03:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235037 - head/contrib/netcat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:03:40 -0000 Author: delphij Date: Fri May 4 21:03:39 2012 New Revision: 235037 URL: http://svn.freebsd.org/changeset/base/235037 Log: Merge from OpenBSD 5.1. MFC after: 3 weeks Modified: head/contrib/netcat/nc.1 head/contrib/netcat/netcat.c Directory Properties: head/contrib/netcat/ (props changed) Modified: head/contrib/netcat/nc.1 ============================================================================== --- head/contrib/netcat/nc.1 Fri May 4 21:00:32 2012 (r235036) +++ head/contrib/netcat/nc.1 Fri May 4 21:03:39 2012 (r235037) @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.57 2011/01/09 22:16:46 jeremy Exp $ +.\" $OpenBSD: nc.1,v 1.60 2012/02/07 12:11:43 lum Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 8, 2011 +.Dd October 4, 2011 .Dt NC 1 .Os .Sh NAME @@ -45,7 +45,7 @@ .Op Fl P Ar proxy_username .Op Fl p Ar source_port .Op Fl s Ar source -.Op Fl T Ar ToS +.Op Fl T Ar toskeyword .Op Fl V Ar rtable .Op Fl w Ar timeout .Op Fl X Ar proxy_protocol @@ -186,14 +186,21 @@ to create and use so that datagrams can It is an error to use this option in conjunction with the .Fl l option. -.It Fl T Ar ToS -Specifies IP Type of Service (ToS) for the connection. -Valid values are the tokens -.Dq lowdelay , -.Dq throughput , -.Dq reliability , -or an 8-bit hexadecimal value preceded by -.Dq 0x . +.It Fl T Ar toskeyword +Change IPv4 TOS value. +.Ar toskeyword +may be one of +.Ar critical , +.Ar inetcontrol , +.Ar lowdelay , +.Ar netcontrol , +.Ar throughput , +.Ar reliability , +or one of the DiffServ Code Points: +.Ar ef , +.Ar af11 ... af43 , +.Ar cs0 ... cs7 ; +or a number in either hex or decimal. .It Fl t Causes .Nm @@ -227,9 +234,9 @@ Have .Nm give more verbose output. .It Fl w Ar timeout -If a connection and stdin are idle for more than +Connections which cannot be established or are idle timeout after .Ar timeout -seconds, then the connection is silently closed. +seconds. The .Fl w flag has no effect on the @@ -480,8 +487,15 @@ Original implementation by *Hobbit* Rewritten with IPv6 support by .An Eric Jackson Aq ericj@monkey.org . .Sh CAVEATS -UDP port scans will always succeed -(i.e. report the port as open), -rendering the +UDP port scans using the .Fl uz -combination of flags relatively useless. +combination of flags will always report success irrespective of +the target machine's state. +However, +in conjunction with a traffic sniffer either on the target machine +or an intermediary device, +the +.Fl uz +combination could be useful for communications diagnostics. +Note that the amount of UDP traffic generated may be limited either +due to hardware resources and/or configuration settings. Modified: head/contrib/netcat/netcat.c ============================================================================== --- head/contrib/netcat/netcat.c Fri May 4 21:00:32 2012 (r235036) +++ head/contrib/netcat/netcat.c Fri May 4 21:03:39 2012 (r235037) @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.101 2011/06/21 17:31:07 mikeb Exp $ */ +/* $OpenBSD: netcat.c,v 1.105 2012/02/09 06:25:35 lum Exp $ */ /* * Copyright (c) 2001 Eric Jackson * @@ -107,6 +107,7 @@ void help(void); int local_listen(char *, char *, struct addrinfo); void readwrite(int); int remote_connect(const char *, const char *, struct addrinfo); +int timeout_connect(int, const struct sockaddr *, socklen_t); int socks_connect(const char *, const char *, struct addrinfo, const char *, const char *, struct addrinfo, int, const char *); int udptest(int); @@ -114,7 +115,7 @@ int unix_bind(char *); int unix_connect(char *); int unix_listen(char *); void set_common_sockopts(int); -int parse_iptos(char *); +int map_tos(char *, int *); void usage(int); #ifdef IPSEC @@ -281,7 +282,18 @@ main(int argc, char *argv[]) Sflag = 1; break; case 'T': - Tflag = parse_iptos(optarg); + errstr = NULL; + errno = 0; + if (map_tos(optarg, &Tflag)) + break; + if (strlen(optarg) > 1 && optarg[0] == '0' && + optarg[1] == 'x') + Tflag = (int)strtol(optarg, NULL, 16); + else + Tflag = (int)strtonum(optarg, 0, 255, + &errstr); + if (Tflag < 0 || Tflag > 255 || errstr || errno) + errx(1, "illegal tos value %s", optarg); break; default: usage(1); @@ -633,7 +645,7 @@ remote_connect(const char *host, const c set_common_sockopts(s); - if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0) + if (timeout_connect(s, res0->ai_addr, res0->ai_addrlen) == 0) break; else if (vflag) warn("connect to %s port %s (%s) failed", host, port, @@ -648,6 +660,43 @@ remote_connect(const char *host, const c return (s); } +int +timeout_connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + struct pollfd pfd; + socklen_t optlen; + int flags, optval; + int ret; + + if (timeout != -1) { + flags = fcntl(s, F_GETFL, 0); + if (fcntl(s, F_SETFL, flags | O_NONBLOCK) == -1) + err(1, "set non-blocking mode"); + } + + if ((ret = connect(s, name, namelen)) != 0 && errno == EINPROGRESS) { + pfd.fd = s; + pfd.events = POLLOUT; + if ((ret = poll(&pfd, 1, timeout)) == 1) { + optlen = sizeof(optval); + if ((ret = getsockopt(s, SOL_SOCKET, SO_ERROR, + &optval, &optlen)) == 0) { + errno = optval; + ret = optval == 0 ? 0 : -1; + } + } else if (ret == 0) { + errno = ETIMEDOUT; + ret = -1; + } else + err(1, "poll failed"); + } + + if (timeout != -1 && fcntl(s, F_SETFL, flags) == -1) + err(1, "restoring flags"); + + return (ret); +} + /* * local_listen() * Returns a socket listening on a local port, binds to specified source @@ -818,7 +867,7 @@ atelnet(int nfd, unsigned char *buf, uns /* * build_ports() - * Build an array or ports in portlist[], listing each port + * Build an array of ports in portlist[], listing each port * that we should try to connect to. */ void @@ -830,9 +879,6 @@ build_ports(char *p) int x = 0; if ((n = strchr(p, '-')) != NULL) { - if (lflag) - errx(1, "Cannot use -l with multiple ports!"); - *n = '\0'; n++; @@ -884,8 +930,7 @@ build_ports(char *p) /* * udptest() * Do a few writes to see if the UDP port is there. - * XXX - Better way of doing this? Doesn't work for IPv6. - * Also fails after around 100 ports checked. + * Fails once PF state table is full. */ int udptest(int s) @@ -946,20 +991,51 @@ set_common_sockopts(int s) } int -parse_iptos(char *s) +map_tos(char *s, int *val) { - int tos = -1; + /* DiffServ Codepoints and other TOS mappings */ + const struct toskeywords { + const char *keyword; + int val; + } *t, toskeywords[] = { + { "af11", IPTOS_DSCP_AF11 }, + { "af12", IPTOS_DSCP_AF12 }, + { "af13", IPTOS_DSCP_AF13 }, + { "af21", IPTOS_DSCP_AF21 }, + { "af22", IPTOS_DSCP_AF22 }, + { "af23", IPTOS_DSCP_AF23 }, + { "af31", IPTOS_DSCP_AF31 }, + { "af32", IPTOS_DSCP_AF32 }, + { "af33", IPTOS_DSCP_AF33 }, + { "af41", IPTOS_DSCP_AF41 }, + { "af42", IPTOS_DSCP_AF42 }, + { "af43", IPTOS_DSCP_AF43 }, + { "critical", IPTOS_PREC_CRITIC_ECP }, + { "cs0", IPTOS_DSCP_CS0 }, + { "cs1", IPTOS_DSCP_CS1 }, + { "cs2", IPTOS_DSCP_CS2 }, + { "cs3", IPTOS_DSCP_CS3 }, + { "cs4", IPTOS_DSCP_CS4 }, + { "cs5", IPTOS_DSCP_CS5 }, + { "cs6", IPTOS_DSCP_CS6 }, + { "cs7", IPTOS_DSCP_CS7 }, + { "ef", IPTOS_DSCP_EF }, + { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, + { "lowdelay", IPTOS_LOWDELAY }, + { "netcontrol", IPTOS_PREC_NETCONTROL }, + { "reliability", IPTOS_RELIABILITY }, + { "throughput", IPTOS_THROUGHPUT }, + { NULL, -1 }, + }; + + for (t = toskeywords; t->keyword != NULL; t++) { + if (strcmp(s, t->keyword) == 0) { + *val = t->val; + return (1); + } + } - if (strcmp(s, "lowdelay") == 0) - return (IPTOS_LOWDELAY); - if (strcmp(s, "throughput") == 0) - return (IPTOS_THROUGHPUT); - if (strcmp(s, "reliability") == 0) - return (IPTOS_RELIABILITY); - - if (sscanf(s, "0x%x", &tos) != 1 || tos < 0 || tos > 0xff) - errx(1, "invalid IP Type of Service"); - return (tos); + return (0); } void @@ -990,7 +1066,7 @@ help(void) \t-r Randomize remote ports\n\ \t-S Enable the TCP MD5 signature option\n\ \t-s addr\t Local source address\n\ - \t-T ToS\t Set IP Type of Service\n\ + \t-T toskeyword\tSet IP Type of Service\n\ \t-t Answer TELNET negotiation\n\ \t-U Use UNIX domain socket\n\ \t-u UDP mode\n\ From owner-svn-src-head@FreeBSD.ORG Fri May 4 21:06:53 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E25E5106566C; Fri, 4 May 2012 21:06:53 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE31B8FC19; Fri, 4 May 2012 21:06:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44L6rrf022909; Fri, 4 May 2012 21:06:53 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44L6rMa022907; Fri, 4 May 2012 21:06:53 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201205042106.q44L6rMa022907@svn.freebsd.org> From: Xin LI Date: Fri, 4 May 2012 21:06:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235038 - head/contrib/netcat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 21:06:54 -0000 Author: delphij Date: Fri May 4 21:06:53 2012 New Revision: 235038 URL: http://svn.freebsd.org/changeset/base/235038 Log: Update FREEBSD-vendor to reflect the current version. Modified: head/contrib/netcat/FREEBSD-vendor Modified: head/contrib/netcat/FREEBSD-vendor ============================================================================== --- head/contrib/netcat/FREEBSD-vendor Fri May 4 21:03:39 2012 (r235037) +++ head/contrib/netcat/FREEBSD-vendor Fri May 4 21:06:53 2012 (r235038) @@ -1,5 +1,5 @@ # $FreeBSD$ Project: netcat (aka src/usr.bin/nc in OpenBSD) ProjectURL: http://www.openbsd.org/ -Version: 4.7 +Version: 5.1 License: BSD From owner-svn-src-head@FreeBSD.ORG Fri May 4 22:54:55 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 754341065701; Fri, 4 May 2012 22:54:55 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 476BD8FC17; Fri, 4 May 2012 22:54:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44Mstof026558; Fri, 4 May 2012 22:54:55 GMT (envelope-from ambrisko@svn.freebsd.org) Received: (from ambrisko@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44MstHO026556; Fri, 4 May 2012 22:54:55 GMT (envelope-from ambrisko@svn.freebsd.org) Message-Id: <201205042254.q44MstHO026556@svn.freebsd.org> From: Doug Ambrisko Date: Fri, 4 May 2012 22:54:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235040 - head/sys/dev/mfi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 22:54:55 -0000 Author: ambrisko Date: Fri May 4 22:54:54 2012 New Revision: 235040 URL: http://svn.freebsd.org/changeset/base/235040 Log: Fix the returns in mfi_tbolt_sync_map_info. I forgot to change them to cleanup and goto out when acknowledging the LD's. Check for failure on malloc. Remove a couple of extra lines and remove the spurious return. Prompted by: Petr Lampa MFC after: 3 days Modified: head/sys/dev/mfi/mfi_tbolt.c Modified: head/sys/dev/mfi/mfi_tbolt.c ============================================================================== --- head/sys/dev/mfi/mfi_tbolt.c Fri May 4 22:48:44 2012 (r235039) +++ head/sys/dev/mfi/mfi_tbolt.c Fri May 4 22:54:54 2012 (r235040) @@ -1290,7 +1290,6 @@ mfi_process_fw_state_chg_isr(void *arg) mtx_unlock(&sc->mfi_io_lock); } - /* * The ThunderBolt HW has an option for the driver to directly * access the underlying disks and operate on the RAID. To @@ -1362,13 +1361,21 @@ mfi_tbolt_sync_map_info(struct mfi_softc mtx_unlock(&sc->mfi_io_lock); ld_sync = (union mfi_ld_ref *) malloc(ld_size, M_MFIBUF, M_WAITOK | M_ZERO); + if (ld_sync == NULL) { + device_printf(sc->mfi_dev, "Failed to allocate sync\n"); + goto out; + } for (i = 0; i < list->ld_count; i++) { ld_sync[i].ref = list->ld_list[i].ld.ref; } mtx_lock(&sc->mfi_io_lock); - if ((cmd = mfi_dequeue_free(sc)) == NULL) - return; + if ((cmd = mfi_dequeue_free(sc)) == NULL) { + device_printf(sc->mfi_dev, "Failed to get command\n"); + free(ld_sync, M_MFIBUF); + goto out; + } + context = cmd->cm_frame->header.context; bzero(cmd->cm_frame, sizeof(union mfi_frame)); cmd->cm_frame->header.context = context; @@ -1396,7 +1403,10 @@ mfi_tbolt_sync_map_info(struct mfi_softc if ((error = mfi_mapcmd(sc, cmd)) != 0) { device_printf(sc->mfi_dev, "failed to send map sync\n"); - return; + free(ld_sync, M_MFIBUF); + sc->mfi_map_sync_cm = NULL; + mfi_requeue_ready(cmd); + goto out; } out: @@ -1405,11 +1415,8 @@ out: if (cm) mfi_release_command(cm); mtx_unlock(&sc->mfi_io_lock); - - return; } - static void mfi_sync_map_complete(struct mfi_command *cm) { From owner-svn-src-head@FreeBSD.ORG Fri May 4 23:16:30 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 45C97106564A; Fri, 4 May 2012 23:16:30 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30F2E8FC1B; Fri, 4 May 2012 23:16:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44NGUmF027295; Fri, 4 May 2012 23:16:30 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44NGTUM027293; Fri, 4 May 2012 23:16:30 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201205042316.q44NGTUM027293@svn.freebsd.org> From: Marcel Moolenaar Date: Fri, 4 May 2012 23:16:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235041 - head/sys/ia64/ia64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 23:16:30 -0000 Author: marcel Date: Fri May 4 23:16:29 2012 New Revision: 235041 URL: http://svn.freebsd.org/changeset/base/235041 Log: Don't assume we have legacy PICs (i.e. 8259A in cascade) at the legacy I/O port addresses. Even if we do, this is hardly the place to mask interrupts. It's not clear that this was at all needed. The code came with CVS revision 1.2 of nexus.c when interrupt support was first added. What is known is that ia64 has always been designed around the IOSAPIC, and that doing I/O like this prevents Altix from booting. Modified: head/sys/ia64/ia64/nexus.c Modified: head/sys/ia64/ia64/nexus.c ============================================================================== --- head/sys/ia64/ia64/nexus.c Fri May 4 22:54:54 2012 (r235040) +++ head/sys/ia64/ia64/nexus.c Fri May 4 23:16:29 2012 (r235041) @@ -65,9 +65,6 @@ #include -#include -#include - #include "clock_if.h" static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); @@ -191,12 +188,6 @@ static int nexus_attach(device_t dev) { - /* - * Mask the legacy PICs - we will use the I/O SAPIC for interrupt. - */ - outb(IO_ICU1+1, 0xff); - outb(IO_ICU2+1, 0xff); - if (acpi_identify() == 0) BUS_ADD_CHILD(dev, 10, "acpi", 0); clock_register(dev, 1000); From owner-svn-src-head@FreeBSD.ORG Fri May 4 23:45:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 126A3106566C; Fri, 4 May 2012 23:45:35 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F11998FC12; Fri, 4 May 2012 23:45:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q44NjYdp028266; Fri, 4 May 2012 23:45:34 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q44NjYJq028264; Fri, 4 May 2012 23:45:34 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201205042345.q44NjYJq028264@svn.freebsd.org> From: Jim Harris Date: Fri, 4 May 2012 23:45:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235043 - head/sys/dev/isci/scil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2012 23:45:35 -0000 Author: jimharris Date: Fri May 4 23:45:34 2012 New Revision: 235043 URL: http://svn.freebsd.org/changeset/base/235043 Log: Fix off-by-one error in sati_inquiry_block_device_translate_data(). Bug would result in INQUIRY VPD 0x81 to SATA devices to return only 63 bytes of data instead of 64 during SCSI/ATA translation. Sponsored by: Intel Approved by: scottl MFC after: 1 week Modified: head/sys/dev/isci/scil/sati_inquiry.c Modified: head/sys/dev/isci/scil/sati_inquiry.c ============================================================================== --- head/sys/dev/isci/scil/sati_inquiry.c Fri May 4 23:33:40 2012 (r235042) +++ head/sys/dev/isci/scil/sati_inquiry.c Fri May 4 23:45:34 2012 (r235043) @@ -359,7 +359,7 @@ void sati_inquiry_block_device_translate ); //bytes 8-63 are reserved - for(offset = 8; offset < 63; offset++) + for(offset = 8; offset < 64; offset++) { sati_set_data_byte(sequence, scsi_io, offset, 0x00); } From owner-svn-src-head@FreeBSD.ORG Sat May 5 02:01:54 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74B23106566C; Sat, 5 May 2012 02:01:54 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-pz0-f48.google.com (mail-pz0-f48.google.com [209.85.210.48]) by mx1.freebsd.org (Postfix) with ESMTP id DA5D58FC16; Sat, 5 May 2012 02:01:53 +0000 (UTC) Received: by dadz8 with SMTP id z8so764299dad.7 for ; Fri, 04 May 2012 19:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=DBs7o3NgfNe4MBGVwx7I4KiZoavHlekxoSzgvCNHz4U=; b=I8MWye9ssHfrSFfXiPXb4lHJDaqRUXdSl7aLQ655lBaVvmO6JuXHyfQ+2TARfmeLJf yoqiM4bKFS/9IpWdwOH5Acie0SKOFsB7qvcOvmZYkaPuUEMnmfHf8FE5Lp6jG3GjwnuN Be5xifVRHUUKYqWcN4OZNbkfd64wXggdNnSIFykFQlR3gquMOCo0z165OTn4SlGtGN1U quG13DQHkb6niaIiA9z2SUrAV2KnT9dUC95YgdaEPsMw2FMNow3WWYdjtJVFwg4lm+R7 Fk+sfr1GXJTASiCmcKd3S9ofU1UZiBBDi/A9ZZAozVLC++9HH+mvyndV1H3o4wLUScCu X7Mw== Received: by 10.68.129.131 with SMTP id nw3mr24089054pbb.150.1336183313265; Fri, 04 May 2012 19:01:53 -0700 (PDT) Received: from fuji.netgear.com ([50.125.30.143]) by mx.google.com with ESMTPS id pl8sm10288790pbb.72.2012.05.04.19.01.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 19:01:51 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1257) Content-Type: text/plain; charset=us-ascii From: Garrett Cooper In-Reply-To: <20120504182200.GD1604@azathoth.lan> Date: Fri, 4 May 2012 19:01:43 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201205041531.q44FVaYF010236@svn.freebsd.org> <20120504182200.GD1604@azathoth.lan> To: Baptiste Daroussin X-Mailer: Apple Mail (2.1257) Cc: Josh Paetzel , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "kmoore@freebsd.org" Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 02:01:54 -0000 On May 4, 2012, at 11:22 AM, Baptiste Daroussin wrote: > On Fri, May 04, 2012 at 09:33:38AM -0700, Garrett Cooper wrote: ... >> Bug; should be '$SIZE/' >=20 > No this is perfectly valid Appreciate the clarification. I guess that's what I get for being = impatient and not testing my claim before I fired it off. Thanks! -Garrett= From owner-svn-src-head@FreeBSD.ORG Sat May 5 07:15:35 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 93D8A106566C; Sat, 5 May 2012 07:15:35 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F1158FC12; Sat, 5 May 2012 07:15:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q457FZVE044680; Sat, 5 May 2012 07:15:35 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q457FZ6v044678; Sat, 5 May 2012 07:15:35 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205050715.q457FZ6v044678@svn.freebsd.org> From: Warner Losh Date: Sat, 5 May 2012 07:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235050 - head/sys/arm/arm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 07:15:35 -0000 Author: imp Date: Sat May 5 07:15:34 2012 New Revision: 235050 URL: http://svn.freebsd.org/changeset/base/235050 Log: Big endian arm boxes need to have a uname -m of armeb, not arm, so that the bootstrap from source works correctly. MFC after: 4 days Modified: head/sys/arm/arm/identcpu.c Modified: head/sys/arm/arm/identcpu.c ============================================================================== --- head/sys/arm/arm/identcpu.c Sat May 5 02:53:19 2012 (r235049) +++ head/sys/arm/arm/identcpu.c Sat May 5 07:15:34 2012 (r235050) @@ -52,11 +52,16 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#if _BYTE_ORDER == _LITTLE_ENDIAN char machine[] = "arm"; +#else +char machine[] = "armeb"; +#endif SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "Machine class"); From owner-svn-src-head@FreeBSD.ORG Sat May 5 09:00:37 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DD1A61065670; Sat, 5 May 2012 09:00:37 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 769D88FC18; Sat, 5 May 2012 09:00:37 +0000 (UTC) Received: by obcni5 with SMTP id ni5so6738443obc.13 for ; Sat, 05 May 2012 02:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=xqr69o3CTQoJj+Ho49hoaEt6TRilPLGAFxUkppVt7no=; b=w7EDYHimnsMicAgOZPr0KwoonnDMeqUGiRkq/PFuXutTHjC3XYo99PAAfDxn4WzrM7 jabOOQEhV5d1L6utj065iKBn9aGq68Tt1Y+dXHkP3H4gPI3Poiwt0qO+SE86QMvb0Z+J ogVmlqn+n7pUgLWsV0vk2q0jIoAEi7hlnANFLCPTBUYUb/zB68+vbyIq7+WnuFWX4VAC MtNj+rUvoDXSmQkTpuV9iTch/VIHaOovr60yi2WljsBrzlI9O7qELDxe4rOTnfgN+viz mGh38/ZB9gf2qYHnDiTrW0KpNiLu6Bu5bX6ZbKqzS/Kf4j2eGR9KtOrKEd5Dk52vsBnc E2Rw== MIME-Version: 1.0 Received: by 10.50.77.136 with SMTP id s8mr4715373igw.56.1336208436761; Sat, 05 May 2012 02:00:36 -0700 (PDT) Sender: pluknet@gmail.com Received: by 10.64.78.37 with HTTP; Sat, 5 May 2012 02:00:36 -0700 (PDT) In-Reply-To: <201204171628.q3HGSM9P089821@svn.freebsd.org> References: <201204171628.q3HGSM9P089821@svn.freebsd.org> Date: Sat, 5 May 2012 13:00:36 +0400 X-Google-Sender-Auth: QgBU9HaeY3rK0I7x9S5TWJX3IXM Message-ID: From: Sergey Kandaurov To: Kirk McKusick Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r234386 - in head/sys: fs/coda fs/ext2fs fs/msdosfs fs/nfsclient kern nfsclient sys ufs/ffs ufs/ufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:00:38 -0000 On 17 April 2012 20:28, Kirk McKusick wrote: > Author: mckusick > Date: Tue Apr 17 16:28:22 2012 > New Revision: 234386 > URL: http://svn.freebsd.org/changeset/base/234386 > > Log: > =A0Replace the MNT_VNODE_FOREACH interface with MNT_VNODE_FOREACH_ALL. > =A0The primary changes are that the user of the interface no longer > =A0needs to manage the mount-mutex locking and that the vnode that > =A0is returned has its mutex locked (thus avoiding the need to check > =A0to see if its is DOOMED or other possible end of life senarios). > > =A0To minimize compatibility issues for third-party developers, the > =A0old MNT_VNODE_FOREACH interface will remain available so that this > =A0change can be MFC'ed to 9. Following the MFC to 9, MNT_VNODE_FOREACH > =A0will be removed in head. > > =A0The reason for this update is to prepare for the addition of the > =A0MNT_VNODE_FOREACH_ACTIVE interface that will loop over just the > =A0active vnodes associated with a mount point (typically less than > =A01% of the vnodes associated with the mount point). > > =A0Reviewed by: kib > =A0Tested by: =A0 Peter Holm > =A0MFC after: =A0 2 weeks > Hi. This commit crashes on old nfsclient. Looks like this change is missed. Index: nfsclient/nfs_vfsops.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- nfsclient/nfs_vfsops.c (revision 235051) +++ nfsclient/nfs_vfsops.c (working copy) @@ -1452,6 +1452,7 @@ MNT_IUNLOCK(mp); return (EBADF); } + MNT_IUNLOCK(mp); /* * Force stale buffer cache information to be flushed. [...] > > Modified: head/sys/nfsclient/nfs_vfsops.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/nfsclient/nfs_vfsops.c Tue Apr 17 14:54:00 2012 (= r234385) > +++ head/sys/nfsclient/nfs_vfsops.c Tue Apr 17 16:28:22 2012 (= r234386) > @@ -1457,19 +1457,15 @@ nfs_sync(struct mount *mp, int waitfor) > * Force stale buffer cache information to be flushed. > */ > loop: > - MNT_VNODE_FOREACH(vp, mp, mvp) { > - VI_LOCK(vp); > - MNT_IUNLOCK(mp); > + MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { Now this call results in malloc() and MNT_ILOCK(mp) inside __mnt_vnode_first_all(). But MNT_ILOCK(mp) is already done few lines above (probably because its MNT_IUNLOCK() counterpart was missed in this commit?). [...] > +struct vnode * > +__mnt_vnode_first_all(struct vnode **mvp, struct mount *mp) > +{ > + =A0 =A0 =A0 struct vnode *vp; > + To the moment it already holds MNT_ILOCK(mp) from sys/nfsclient/nfs_vfsops.c:1445 > + =A0 =A0 =A0 *mvp =3D malloc(sizeof(struct vnode), M_VNODE_MARKER, M_WAI= TOK | M_ZERO); > + =A0 =A0 =A0 MNT_ILOCK(mp); > + =A0 =A0 =A0 MNT_REF(mp); > + =A0 =A0 =A0 (*mvp)->v_type =3D VMARKER; > + > + =A0 =A0 =A0 vp =3D TAILQ_FIRST(&mp->mnt_nvnodelist); > + =A0 =A0 =A0 while (vp !=3D NULL && (vp->v_type =3D=3D VMARKER || > + =A0 =A0 =A0 =A0 =A0 (vp->v_iflag & VI_DOOMED) !=3D 0)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 vp =3D TAILQ_NEXT(vp, v_nmntvnodes); > + > + =A0 =A0 =A0 /* Check if we are done */ > + =A0 =A0 =A0 if (vp =3D=3D NULL) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 *mvp =3D NULL; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MNT_REL(mp); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MNT_IUNLOCK(mp); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 free(*mvp, M_VNODE_MARKER); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (NULL); > + =A0 =A0 =A0 } > + =A0 =A0 =A0 (*mvp)->v_mount =3D mp; > + =A0 =A0 =A0 TAILQ_INSERT_AFTER(&mp->mnt_nvnodelist, vp, *mvp, v_nmntvno= des); > + =A0 =A0 =A0 VI_LOCK(vp); > + =A0 =A0 =A0 MNT_IUNLOCK(mp); > + =A0 =A0 =A0 return (vp); > +} [...] uma_zalloc_arg: zone "1024" with the following non-sleepable locks held: exclusive sleep mutex struct mount mtx (struct mount mtx) r =3D 0 (0xfffffe0002907750) locked @ /usr/src/sys/nfsclient/nfs_vfsops.c:1445 KDB: stack backtrace: db_trace_self_wrapper() at 0xffffffff802c75aa =3D db_trace_self_wrapper+0x2= a kdb_backtrace() at 0xffffffff80476547 =3D kdb_backtrace+0x37 _witness_debugger() at 0xffffffff8048d48c =3D _witness_debugger+0x2c witness_warn() at 0xffffffff8048e274 =3D witness_warn+0x2c4 uma_zalloc_arg() at 0xffffffff8068be24 =3D uma_zalloc_arg+0x384 malloc() at 0xffffffff80425026 =3D malloc+0xc6 __mnt_vnode_first_all() at 0xffffffff804dd3f9 =3D __mnt_vnode_first_all+0x2= 9 nfs_sync() at 0xffffffff805f231d =3D nfs_sync+0x8d sys_sync() at 0xffffffff804e8906 =3D sys_sync+0x146 amd64_syscall() at 0xffffffff806c780c =3D amd64_syscall+0x38c Xfast_syscall() at 0xffffffff806b2c47 =3D Xfast_syscall+0xf7 --- syscall (36, FreeBSD ELF64, sys_sync), rip =3D 0x800a95a0c, rsp =3D 0x7fffffffd958, rbp =3D 0x7fffffffdd50 --- panic: _mtx_lock_sleep: recursed on non-recursive mutex struct mount mtx @ /usr/src/sys/kern/vfs_subr.c:4595 cpuid =3D 1 KDB: stack backtrace: db_trace_self_wrapper() at 0xffffffff802c75aa =3D db_trace_self_wrapper+0x2= a kdb_backtrace() at 0xffffffff80476547 =3D kdb_backtrace+0x37 panic() at 0xffffffff8043bc3e =3D panic+0x1ce _mtx_lock_sleep() at 0xffffffff80429058 =3D _mtx_lock_sleep+0x538 _mtx_lock_flags() at 0xffffffff804291e4 =3D _mtx_lock_flags+0x184 __mnt_vnode_first_all() at 0xffffffff804dd413 =3D __mnt_vnode_first_all+0x4= 3 nfs_sync() at 0xffffffff805f231d =3D nfs_sync+0x8d sys_sync() at 0xffffffff804e8906 =3D sys_sync+0x146 amd64_syscall() at 0xffffffff806c780c =3D amd64_syscall+0x38c Xfast_syscall() at 0xffffffff806b2c47 =3D Xfast_syscall+0xf7 --- syscall (36, FreeBSD ELF64, sys_sync), rip =3D 0x800a95a0c, rsp =3D 0x7fffffffd958, rbp =3D 0x7fffffffdd50 --- KDB: enter: panic [ thread pid 1268 tid 100085 ] Stopped at 0xffffffff8047620b =3D kdb_enter+0x3b: movq $0,0x75d252(%rip) db> --=20 wbr, pluknet From owner-svn-src-head@FreeBSD.ORG Sat May 5 09:13:42 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5B323106566C; Sat, 5 May 2012 09:13:42 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail17.syd.optusnet.com.au (mail17.syd.optusnet.com.au [211.29.132.198]) by mx1.freebsd.org (Postfix) with ESMTP id E83048FC0C; Sat, 5 May 2012 09:13:41 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail17.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q459DXEe017745 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 May 2012 19:13:34 +1000 Date: Sat, 5 May 2012 19:13:33 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Pawel Jakub Dawidek In-Reply-To: <20120504185743.GA1397@garage.freebsd.pl> Message-ID: <20120505185603.G1113@besplex.bde.org> References: <201203242110.q2OLAJSZ049045@svn.freebsd.org> <20120504185743.GA1397@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler Subject: Re: svn commit: r233435 - head/etc/mtree X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:13:42 -0000 On Fri, 4 May 2012, Pawel Jakub Dawidek wrote: > On Sat, Mar 24, 2012 at 09:10:19PM +0000, Eitan Adler wrote: >> Log: >> Fix build by adding new directory to mtree in r233429 >> >> Submitted by: flo >> Approved by: cperciva >> MFC after: 1 week >> >> Modified: >> head/etc/mtree/BSD.usr.dist >> >> Modified: head/etc/mtree/BSD.usr.dist >> ============================================================================== >> --- head/etc/mtree/BSD.usr.dist Sat Mar 24 19:59:14 2012 (r233434) >> +++ head/etc/mtree/BSD.usr.dist Sat Mar 24 21:10:19 2012 (r233435) >> @@ -209,6 +209,8 @@ >> .. >> bootforth >> .. >> + csh >> + .. >> cvs > > You need to use only spaces in this file for indentation just like in > all the other lines. That's a shame it was merged into 7, 8 and 9. Of course, it doesn't help that mtree files are among the few whose formatting style is specified in detail (in mtree/README). BSD.usr.dist is the only one that has any tabs (82 lines out of 1364). Other misformattings are harder to grep for, but unlikely to be null. A relatively serious ones (equivalent to leaving out necessary braces for a compound statement in C) is visible in the above: the tab for the ".." for csh is not just a style bug, but misindents to an extra level, so the level can't be read off from the indentation. This is without spurious indentation from mailer quoting or tab mis-expansion; in this reply, the mailer quoting combined with only some lines using tabs makes it look like "csh" is missing indentation instead of its ".." having extra indentation. The strings are "<4 spaces>csh" and .." but should be "<12 spaces>" for both.) There is no indent(1) for mtree files, but the README has instructions for producing the correct formatting by running mtree(1) with suitable options. Bruce From owner-svn-src-head@FreeBSD.ORG Sat May 5 09:34:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 336801065672; Sat, 5 May 2012 09:34:36 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E3708FC08; Sat, 5 May 2012 09:34:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q459YZJZ049094; Sat, 5 May 2012 09:34:35 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q459YZol049092; Sat, 5 May 2012 09:34:35 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201205050934.q459YZol049092@svn.freebsd.org> From: Sergey Kandaurov Date: Sat, 5 May 2012 09:34:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235052 - head/sys/nfsclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:34:36 -0000 Author: pluknet Date: Sat May 5 09:34:35 2012 New Revision: 235052 URL: http://svn.freebsd.org/changeset/base/235052 Log: Fix mount mutex handling missed in r234386. Modified: head/sys/nfsclient/nfs_vfsops.c Modified: head/sys/nfsclient/nfs_vfsops.c ============================================================================== --- head/sys/nfsclient/nfs_vfsops.c Sat May 5 07:55:50 2012 (r235051) +++ head/sys/nfsclient/nfs_vfsops.c Sat May 5 09:34:35 2012 (r235052) @@ -1452,6 +1452,7 @@ nfs_sync(struct mount *mp, int waitfor) MNT_IUNLOCK(mp); return (EBADF); } + MNT_IUNLOCK(mp); /* * Force stale buffer cache information to be flushed. From owner-svn-src-head@FreeBSD.ORG Sat May 5 09:39:19 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 041801065670; Sat, 5 May 2012 09:39:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx07.syd.optusnet.com.au (fallbackmx07.syd.optusnet.com.au [211.29.132.9]) by mx1.freebsd.org (Postfix) with ESMTP id 870348FC1C; Sat, 5 May 2012 09:39:18 +0000 (UTC) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by fallbackmx07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q459dAbm026515; Sat, 5 May 2012 19:39:10 +1000 Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q459d1OR028213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 May 2012 19:39:02 +1000 Date: Sat, 5 May 2012 19:39:01 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Doug Barton In-Reply-To: <4FA438C4.3080701@FreeBSD.org> Message-ID: <20120505192318.T1202@besplex.bde.org> References: <201205041531.q44FVaYF010236@svn.freebsd.org> <20120504182200.GD1604@azathoth.lan> <4FA438C4.3080701@FreeBSD.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Baptiste Daroussin , "src-committers@freebsd.org" , Garrett Cooper , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" , "kmoore@freebsd.org" , Josh Paetzel Subject: Re: svn commit: r235005 - head/usr.sbin/pc-sysinstall/backend X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 09:39:19 -0000 On Fri, 4 May 2012, Doug Barton wrote: > On 05/04/2012 11:22 AM, Baptiste Daroussin wrote: >>>>>> fetch -s "${FETCHFILE}" >${SIZEFILE} >>>>>> SIZE="`cat ${SIZEFILE}`" >>>>>> - SIZE="`expr ${SIZE} / 1024`" >>>>>> + SIZE=$((SIZE/1024)) >>>> >>>> Bug; should be '$SIZE/' >> No this is perfectly valid > > Yes, that works, but it's not our usual style. However, the point is > moot as that whole block should be reduced down to: > > SIZE=$(( `fetch -s "${FETCHFILE}"` / 1024 )) The KNF rule that there shall be spaces around binary operators should probably apply in shell expressions too, but I don't like the spaces on 1 side of (( and )). Shell syntax doesn't even allow spaces between '$' ((. The rc.d style seems to be to use backquotes and not use $(cmd), but I prefer the opposite except possibly in shell expressions like the above so that it is easier to separate the commands from the shell expressions. > If SIZEFILE is needed elsewhere that's a different matter, but as it is > that's a hot mess. Bruce From owner-svn-src-head@FreeBSD.ORG Sat May 5 11:11:31 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 62A45106566B; Sat, 5 May 2012 11:11:31 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id EFA028FC0A; Sat, 5 May 2012 11:11:30 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q45BBO02076502; Sat, 5 May 2012 14:11:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q45BBOPX089033; Sat, 5 May 2012 14:11:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q45BBOuE089032; Sat, 5 May 2012 14:11:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 5 May 2012 14:11:24 +0300 From: Konstantin Belousov To: Sergey Kandaurov Message-ID: <20120505111124.GW2358@deviant.kiev.zoral.com.ua> References: <201204171628.q3HGSM9P089821@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lTD11Lcb85B6e8hZ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Kirk McKusick Subject: Re: svn commit: r234386 - in head/sys: fs/coda fs/ext2fs fs/msdosfs fs/nfsclient kern nfsclient sys ufs/ffs ufs/ufs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:11:31 -0000 --lTD11Lcb85B6e8hZ Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 05, 2012 at 01:00:36PM +0400, Sergey Kandaurov wrote: > On 17 April 2012 20:28, Kirk McKusick wrote: > > Author: mckusick > > Date: Tue Apr 17 16:28:22 2012 > > New Revision: 234386 > > URL: http://svn.freebsd.org/changeset/base/234386 > > > > Log: > > =9AReplace the MNT_VNODE_FOREACH interface with MNT_VNODE_FOREACH_ALL. > > =9AThe primary changes are that the user of the interface no longer > > =9Aneeds to manage the mount-mutex locking and that the vnode that > > =9Ais returned has its mutex locked (thus avoiding the need to check > > =9Ato see if its is DOOMED or other possible end of life senarios). > > > > =9ATo minimize compatibility issues for third-party developers, the > > =9Aold MNT_VNODE_FOREACH interface will remain available so that this > > =9Achange can be MFC'ed to 9. Following the MFC to 9, MNT_VNODE_FOREACH > > =9Awill be removed in head. > > > > =9AThe reason for this update is to prepare for the addition of the > > =9AMNT_VNODE_FOREACH_ACTIVE interface that will loop over just the > > =9Aactive vnodes associated with a mount point (typically less than > > =9A1% of the vnodes associated with the mount point). > > > > =9AReviewed by: kib > > =9ATested by: =9A Peter Holm > > =9AMFC after: =9A 2 weeks > > >=20 > Hi. >=20 > This commit crashes on old nfsclient. Looks like this change is missed. >=20 > Index: nfsclient/nfs_vfsops.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- nfsclient/nfs_vfsops.c (revision 235051) > +++ nfsclient/nfs_vfsops.c (working copy) > @@ -1452,6 +1452,7 @@ > MNT_IUNLOCK(mp); > return (EBADF); > } > + MNT_IUNLOCK(mp); >=20 > /* > * Force stale buffer cache information to be flushed. >=20 Yes, looks so. And, for the purposes for which the check of MNTK_UNMOUNTF was added, the interlock of the struct mount is not needed there at all. I suggest that you just remove MNT_ILOCK/partial MNT_IUNLOCK and commit the change. Thanks. --lTD11Lcb85B6e8hZ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+lCtsACgkQC3+MBN1Mb4iXXgCdEPwENnO81zunpeJLET7ZENVr OoAAnj21/9YyyrWjvpj+C+pssi4+Y+De =ohSf -----END PGP SIGNATURE----- --lTD11Lcb85B6e8hZ-- From owner-svn-src-head@FreeBSD.ORG Sat May 5 11:26:09 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E332106564A; Sat, 5 May 2012 11:26:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49A438FC0C; Sat, 5 May 2012 11:26:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45BQ9g5056207; Sat, 5 May 2012 11:26:09 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45BQ9B5056205; Sat, 5 May 2012 11:26:09 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205051126.q45BQ9B5056205@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 May 2012 11:26:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235054 - head/libexec/rtld-elf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 11:26:09 -0000 Author: kib Date: Sat May 5 11:26:08 2012 New Revision: 235054 URL: http://svn.freebsd.org/changeset/base/235054 Log: Work around a situation where symlook_obj() could be called for the object for which digest_dynamic1() was not done yet. Just return EINVAL and do not try to dereference NULL buckets hash array. This seems to happen on ia64 for rtld object itself, where the R_IA_64_FPTR64LSB relocations require symbol lookup. The dynamic linker itself does not rely on identity of the C-level function pointers (i.e. function descriptors). Reported and reviewed by: marcel MFC after: 8 days Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Sat May 5 10:05:13 2012 (r235053) +++ head/libexec/rtld-elf/rtld.c Sat May 5 11:26:08 2012 (r235054) @@ -3480,13 +3480,15 @@ symlook_obj(SymLook *req, const Obj_Entr int flags, res, mres; /* - * There is at least one valid hash at this point, and we prefer to use - * the faster GNU version if available. + * If there is at least one valid hash at this point, we prefer to + * use the faster GNU version if available. */ if (obj->valid_hash_gnu) mres = symlook_obj1_gnu(req, obj); - else + else if (obj->valid_hash_sysv) mres = symlook_obj1_sysv(req, obj); + else + return (EINVAL); if (mres == 0) { if (obj->needed_filtees != NULL) { From owner-svn-src-head@FreeBSD.ORG Sat May 5 14:06:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A40311065670; Sat, 5 May 2012 14:06:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 74C7C8FC15; Sat, 5 May 2012 14:06:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45E6GpY061297; Sat, 5 May 2012 14:06:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45E6GNl061295; Sat, 5 May 2012 14:06:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205051406.q45E6GNl061295@svn.freebsd.org> From: Michael Tuexen Date: Sat, 5 May 2012 14:06:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235057 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 14:06:16 -0000 Author: tuexen Date: Sat May 5 14:06:15 2012 New Revision: 235057 URL: http://svn.freebsd.org/changeset/base/235057 Log: Do error checking for the SCTP_RESET_STREAMS, SCTP_RESET_ASSOC, and SCTP_ADD_STREAMS socket options as specified by RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_usrreq.c Modified: head/sys/netinet/sctp_usrreq.c ============================================================================== --- head/sys/netinet/sctp_usrreq.c Sat May 5 11:34:27 2012 (r235056) +++ head/sys/netinet/sctp_usrreq.c Sat May 5 14:06:15 2012 (r235057) @@ -4164,7 +4164,6 @@ sctp_setopt(struct socket *so, int optna SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_reset_streams, optsize); SCTP_FIND_STCB(inp, stcb, strrst->srs_assoc_id); - if (stcb == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT); error = ENOENT; @@ -4179,15 +4178,6 @@ sctp_setopt(struct socket *so, int optna SCTP_TCB_UNLOCK(stcb); break; } - if (!(stcb->asoc.local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { - /* - * User did not enable the operation. - */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); - error = EPERM; - SCTP_TCB_UNLOCK(stcb); - break; - } if (stcb->asoc.stream_reset_outstanding) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); error = EALREADY; @@ -4246,6 +4236,21 @@ sctp_setopt(struct socket *so, int optna error = ENOENT; break; } + if (stcb->asoc.peer_supports_strreset == 0) { + /* + * Peer does not support the chunk type. + */ + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP); + error = EOPNOTSUPP; + SCTP_TCB_UNLOCK(stcb); + break; + } + if (stcb->asoc.stream_reset_outstanding) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); + error = EALREADY; + SCTP_TCB_UNLOCK(stcb); + break; + } if ((stradd->sas_outstrms == 0) && (stradd->sas_instrms == 0)) { error = EINVAL; @@ -4309,15 +4314,6 @@ sctp_setopt(struct socket *so, int optna SCTP_TCB_UNLOCK(stcb); break; } - if (!(stcb->asoc.local_strreset_support & SCTP_ENABLE_RESET_ASSOC_REQ)) { - /* - * User did not enable the operation. - */ - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EPERM); - error = EPERM; - SCTP_TCB_UNLOCK(stcb); - break; - } if (stcb->asoc.stream_reset_outstanding) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); error = EALREADY; From owner-svn-src-head@FreeBSD.ORG Sat May 5 15:35:23 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9D1D0106564A; Sat, 5 May 2012 15:35:23 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 882B38FC0A; Sat, 5 May 2012 15:35:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45FZNU5064086; Sat, 5 May 2012 15:35:23 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45FZNiW064083; Sat, 5 May 2012 15:35:23 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201205051535.q45FZNiW064083@svn.freebsd.org> From: Dimitry Andric Date: Sat, 5 May 2012 15:35:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235058 - in head: . lib/clang/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 15:35:23 -0000 Author: dim Date: Sat May 5 15:35:22 2012 New Revision: 235058 URL: http://svn.freebsd.org/changeset/base/235058 Log: Make sure a few new internal clang headers get installed, I missed these in the last import. They are sometimes needed when you want to use advanced instructions. Also, add clang's internal stdalign.h header to ObsoleteFiles.inc, since it is redundant: we already have a stdalign.h header in /usr/include. Pointy hat to: dim PR: kern/167574 Submitted by: jkim Reported by: Oliver Hartmann MFC after: 2 weeks Modified: head/ObsoleteFiles.inc head/lib/clang/include/Makefile Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sat May 5 14:06:15 2012 (r235057) +++ head/ObsoleteFiles.inc Sat May 5 15:35:22 2012 (r235058) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20120505: new clang import installed a redundant internal header +OLD_FILES+=usr/include/clang/3.1/stdalign.h # 20120425: libusb version bump (r234684) OLD_LIBS+=usr/lib/libusb.so.2 OLD_LIBS+=usr/lib32/libusb.so.2 Modified: head/lib/clang/include/Makefile ============================================================================== --- head/lib/clang/include/Makefile Sat May 5 14:06:15 2012 (r235057) +++ head/lib/clang/include/Makefile Sat May 5 15:35:22 2012 (r235058) @@ -5,17 +5,23 @@ INCSDIR=${INCLUDEDIR}/clang/3.1 INCS= altivec.h \ + avx2intrin.h \ avxintrin.h \ + bmi2intrin.h \ + bmiintrin.h \ cpuid.h \ emmintrin.h \ + fma4intrin.h \ immintrin.h \ + lzcntintrin.h \ mm3dnow.h \ mm_malloc.h \ mmintrin.h \ + module.map \ nmmintrin.h \ pmmintrin.h \ + popcntintrin.h \ smmintrin.h \ - stdalign.h \ tmmintrin.h \ unwind.h \ wmmintrin.h \ From owner-svn-src-head@FreeBSD.ORG Sat May 5 16:19:19 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BA0E106566C; Sat, 5 May 2012 16:19:19 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from agogare.doit.wisc.edu (agogare.doit.wisc.edu [144.92.197.211]) by mx1.freebsd.org (Postfix) with ESMTP id 69E508FC0A; Sat, 5 May 2012 16:19:19 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth2.wiscmail.wisc.edu by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0M3K00G005C08M00@smtpauth2.wiscmail.wisc.edu>; Sat, 05 May 2012 11:19:12 -0500 (CDT) Received: from comporellon.tachypleus.net ([unknown] [76.210.67.9]) by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0M3K008DY5BS8110@smtpauth2.wiscmail.wisc.edu>; Sat, 05 May 2012 11:19:05 -0500 (CDT) Date: Sat, 05 May 2012 11:19:03 -0500 From: Nathan Whitehorn In-reply-to: <201205050715.q457FZ6v044678@svn.freebsd.org> To: Warner Losh Message-id: <4FA552F7.70306@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=76.210.67.9 X-Spam-PmxInfo: Server=avs-13, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.19.163615, SenderIP=76.210.67.9 References: <201205050715.q457FZ6v044678@svn.freebsd.org> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120429 Thunderbird/12.0 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r235050 - head/sys/arm/arm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:19:19 -0000 On 05/05/12 02:15, Warner Losh wrote: > Author: imp > Date: Sat May 5 07:15:34 2012 > New Revision: 235050 > URL: http://svn.freebsd.org/changeset/base/235050 > > Log: > Big endian arm boxes need to have a uname -m of armeb, not arm, so > that the bootstrap from source works correctly. > > MFC after: 4 days > > Modified: > head/sys/arm/arm/identcpu.c > > Modified: head/sys/arm/arm/identcpu.c > ============================================================================== > --- head/sys/arm/arm/identcpu.c Sat May 5 02:53:19 2012 (r235049) > +++ head/sys/arm/arm/identcpu.c Sat May 5 07:15:34 2012 (r235050) > @@ -52,11 +52,16 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > > #include > #include > > +#if _BYTE_ORDER == _LITTLE_ENDIAN > char machine[] = "arm"; > +#else > +char machine[] = "armeb"; > +#endif > > SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, > machine, 0, "Machine class"); Didn't you mean to change MACHINE_ARCH in /sys/arm/include/param.h? Setting MACHINE=armeb will break lots of things, including self-hosting. -Nathan From owner-svn-src-head@FreeBSD.ORG Sat May 5 16:37:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 514DF106564A; Sat, 5 May 2012 16:37:15 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3CB6B8FC24; Sat, 5 May 2012 16:37:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45GbF7O066079; Sat, 5 May 2012 16:37:15 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45GbFdk066077; Sat, 5 May 2012 16:37:15 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205051637.q45GbFdk066077@svn.freebsd.org> From: Baptiste Daroussin Date: Sat, 5 May 2012 16:37:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235059 - head/libexec/rtld-elf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:37:15 -0000 Author: bapt Date: Sat May 5 16:37:14 2012 New Revision: 235059 URL: http://svn.freebsd.org/changeset/base/235059 Log: open the resolved path fix debug message Submitted by: John Marino Approved by: des (mentor) Modified: head/libexec/rtld-elf/libmap.c Modified: head/libexec/rtld-elf/libmap.c ============================================================================== --- head/libexec/rtld-elf/libmap.c Sat May 5 15:35:22 2012 (r235058) +++ head/libexec/rtld-elf/libmap.c Sat May 5 16:37:14 2012 (r235059) @@ -121,16 +121,16 @@ lmc_parse_file(char *path) } } - fd = open(path, O_RDONLY); + fd = open(rpath, O_RDONLY); if (fd == -1) { - dbg("lm_init: open(\"%s\") failed, %s", path, + dbg("lm_parse_file: open(\"%s\") failed, %s", rpath, rtld_strerror(errno)); free(rpath); return; } if (fstat(fd, &st) == -1) { close(fd); - dbg("lm_init: fstat(\"%s\") failed, %s", path, + dbg("lm_parse_file: fstat(\"%s\") failed, %s", rpath, rtld_strerror(errno)); free(rpath); return; @@ -138,7 +138,7 @@ lmc_parse_file(char *path) lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (lm_map == (const char *)MAP_FAILED) { close(fd); - dbg("lm_init: mmap(\"%s\") failed, %s", path, + dbg("lm_parse_file: mmap(\"%s\") failed, %s", rpath, rtld_strerror(errno)); free(rpath); return; From owner-svn-src-head@FreeBSD.ORG Sat May 5 16:50:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 975171065670; Sat, 5 May 2012 16:50:13 +0000 (UTC) (envelope-from issyl0@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 827EF8FC0C; Sat, 5 May 2012 16:50:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45GoD9a066605; Sat, 5 May 2012 16:50:13 GMT (envelope-from issyl0@svn.freebsd.org) Received: (from issyl0@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45GoDLx066603; Sat, 5 May 2012 16:50:13 GMT (envelope-from issyl0@svn.freebsd.org) Message-Id: <201205051650.q45GoDLx066603@svn.freebsd.org> From: Isabell Long Date: Sat, 5 May 2012 16:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235061 - head/share/misc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 16:50:13 -0000 Author: issyl0 (doc committer) Date: Sat May 5 16:50:12 2012 New Revision: 235061 URL: http://svn.freebsd.org/changeset/base/235061 Log: - Add my mentor/mentee relationship to committers-doc.dot. (where me = issyl0) Approved by: gabor (mentor) Modified: head/share/misc/committers-doc.dot Modified: head/share/misc/committers-doc.dot ============================================================================== --- head/share/misc/committers-doc.dot Sat May 5 16:41:17 2012 (r235060) +++ head/share/misc/committers-doc.dot Sat May 5 16:50:12 2012 (r235061) @@ -60,6 +60,7 @@ ganbold [label="Ganbold Tsagaankhuu\ngan gavin [label="Gavin Atkinson\ngavin@FreeBSD.org\n2011/07/18"] gjb [label="Glen Barber\ngjb@FreeBSD.org\n2010/09/01"] hrs [label="Hiroki Sato\nhrs@FreeBSD.org\n2000/07/06"] +issyl0 [label="Isabell Long\nissyl0@FreeBSD.org\n2012/04/25"] jkois [label="Johann Kois\njkois@FreeBSD.org\n2004/11/11"] joel [label="Joel Dahl\njoel@FreeBSD.org\n2005/04/05"] keramida [label="Giorgos Keramidas\nkeramida@FreeBSD.org\n2001/10/12"] @@ -107,6 +108,7 @@ delphij -> loader gabor -> pgj gabor -> manolis gabor -> taras +gabor -> issyl0 gjb -> wblock From owner-svn-src-head@FreeBSD.ORG Sat May 5 17:16:03 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 00B54106566C; Sat, 5 May 2012 17:16:03 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 83A878FC0A; Sat, 5 May 2012 17:15:59 +0000 (UTC) Received: from 63.imp.bsdimp.com (63.imp.bsdimp.com [10.0.0.63]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id q45H9wZm042807 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Sat, 5 May 2012 11:09:58 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <4FA552F7.70306@freebsd.org> Date: Sat, 5 May 2012 11:09:57 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <887183C8-204F-4240-9CA7-E9295B6219B9@bsdimp.com> References: <201205050715.q457FZ6v044678@svn.freebsd.org> <4FA552F7.70306@freebsd.org> To: Nathan Whitehorn X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Sat, 05 May 2012 11:09:58 -0600 (MDT) Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Warner Losh Subject: Re: svn commit: r235050 - head/sys/arm/arm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 17:16:03 -0000 On May 5, 2012, at 10:19 AM, Nathan Whitehorn wrote: > On 05/05/12 02:15, Warner Losh wrote: >> Author: imp >> Date: Sat May 5 07:15:34 2012 >> New Revision: 235050 >> URL: http://svn.freebsd.org/changeset/base/235050 >>=20 >> Log: >> Big endian arm boxes need to have a uname -m of armeb, not arm, so >> that the bootstrap from source works correctly. >>=20 >> MFC after: 4 days >>=20 >> Modified: >> head/sys/arm/arm/identcpu.c >>=20 >> Modified: head/sys/arm/arm/identcpu.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/arm/arm/identcpu.c Sat May 5 02:53:19 2012 = (r235049) >> +++ head/sys/arm/arm/identcpu.c Sat May 5 07:15:34 2012 = (r235050) >> @@ -52,11 +52,16 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >> #include >> +#include >>=20 >> #include >> #include >>=20 >> +#if _BYTE_ORDER =3D=3D _LITTLE_ENDIAN >> char machine[] =3D "arm"; >> +#else >> +char machine[] =3D "armeb"; >> +#endif >>=20 >> SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, >> machine, 0, "Machine class"); >=20 > Didn't you mean to change MACHINE_ARCH in /sys/arm/include/param.h? = Setting MACHINE=3Darmeb will break lots of things, including = self-hosting. DOh! You're right... I'll fix that. :( Warner From owner-svn-src-head@FreeBSD.ORG Sat May 5 17:20:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AAE06106566B; Sat, 5 May 2012 17:20:12 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 963228FC14; Sat, 5 May 2012 17:20:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45HKCCO067562; Sat, 5 May 2012 17:20:12 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45HKCcw067560; Sat, 5 May 2012 17:20:12 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201205051720.q45HKCcw067560@svn.freebsd.org> From: Warner Losh Date: Sat, 5 May 2012 17:20:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235062 - head/sys/arm/arm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 17:20:12 -0000 Author: imp Date: Sat May 5 17:20:12 2012 New Revision: 235062 URL: http://svn.freebsd.org/changeset/base/235062 Log: I need to change uname -p, not uname -m, so back this out. Also, fix a couple of style(9) issues while I'm here. Submitted by: nathanw, bde Modified: head/sys/arm/arm/identcpu.c Modified: head/sys/arm/arm/identcpu.c ============================================================================== --- head/sys/arm/arm/identcpu.c Sat May 5 16:50:12 2012 (r235061) +++ head/sys/arm/arm/identcpu.c Sat May 5 17:20:12 2012 (r235062) @@ -57,14 +57,10 @@ __FBSDID("$FreeBSD$"); #include #include -#if _BYTE_ORDER == _LITTLE_ENDIAN char machine[] = "arm"; -#else -char machine[] = "armeb"; -#endif SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, - machine, 0, "Machine class"); + machine, 0, "Machine class"); static const char * const generic_steppings[16] = { "rev 0", "rev 1", "rev 2", "rev 3", @@ -140,7 +136,7 @@ static const char * const pxa2x0_steppin }; /* Steppings for PXA255/26x. - * rev 5: PXA26x B0, rev 6: PXA255 A0 + * rev 5: PXA26x B0, rev 6: PXA255 A0 */ static const char * const pxa255_steppings[16] = { "rev 0", "rev 1", "rev 2", "step A-0", @@ -460,7 +456,7 @@ identify_arm_cpu(void) printf(" %dKB/%dB %d-way %s Data cache\n", arm_pdcache_size / 1024, arm_pdcache_line_size, arm_pdcache_ways, - wtnames[arm_pcache_type]); + wtnames[arm_pcache_type]); } } From owner-svn-src-head@FreeBSD.ORG Sat May 5 19:42:39 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F803106566B; Sat, 5 May 2012 19:42:39 +0000 (UTC) (envelope-from netchild@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88CC28FC08; Sat, 5 May 2012 19:42:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45JgdGs072001; Sat, 5 May 2012 19:42:39 GMT (envelope-from netchild@svn.freebsd.org) Received: (from netchild@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45Jgd3P071990; Sat, 5 May 2012 19:42:39 GMT (envelope-from netchild@svn.freebsd.org) Message-Id: <201205051942.q45Jgd3P071990@svn.freebsd.org> From: Alexander Leidinger Date: Sat, 5 May 2012 19:42:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235063 - in head/sys: amd64/linux32 compat/linux i386/linux X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 19:42:39 -0000 Author: netchild Date: Sat May 5 19:42:38 2012 New Revision: 235063 URL: http://svn.freebsd.org/changeset/base/235063 Log: - >500 static DTrace probes for the linuxulator - DTrace scripts to check for errors, performance, ... they serve mostly as examples of what you can do with the static probe;s with moderate load the scripts may be overwhelmed, excessive lock-tracing may influence program behavior (see the last design decission) Design decissions: - use "linuxulator" as the provider for the native bitsize; add the bitsize for the non-native emulation (e.g. "linuxuator32" on amd64) - Add probes only for locks which are acquired in one function and released in another function. Locks which are aquired and released in the same function should be easy to pair in the code, inter-function locking is more easy to verify in DTrace. - Probes for locks should be fired after locking and before releasing to prevent races (to provide data/function stability in DTrace, see the man-page of "dtrace -v ..." and the corresponding DTrace docs). Added: head/sys/compat/linux/check_error.d (contents, props changed) head/sys/compat/linux/check_internal_locks.d (contents, props changed) head/sys/compat/linux/linux_dtrace.h (contents, props changed) head/sys/compat/linux/stats_timing.d (contents, props changed) head/sys/compat/linux/trace_futexes.d (contents, props changed) Modified: head/sys/amd64/linux32/linux.h head/sys/amd64/linux32/linux32_dummy.c head/sys/compat/linux/linux_emul.c head/sys/compat/linux/linux_emul.h head/sys/compat/linux/linux_fork.c head/sys/compat/linux/linux_futex.c head/sys/compat/linux/linux_mib.c head/sys/compat/linux/linux_misc.c head/sys/compat/linux/linux_sysctl.c head/sys/compat/linux/linux_time.c head/sys/compat/linux/linux_uid16.c head/sys/compat/linux/linux_util.c head/sys/compat/linux/linux_util.h head/sys/i386/linux/linux.h head/sys/i386/linux/linux_dummy.c Modified: head/sys/amd64/linux32/linux.h ============================================================================== --- head/sys/amd64/linux32/linux.h Sat May 5 17:20:12 2012 (r235062) +++ head/sys/amd64/linux32/linux.h Sat May 5 19:42:38 2012 (r235063) @@ -42,6 +42,7 @@ extern u_char linux_debug_map[]; #define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name) #define ARGS(nm, fmt) "linux(%ld): "#nm"("fmt")\n", (long)td->td_proc->p_pid #define LMSG(fmt) "linux(%ld): "fmt"\n", (long)td->td_proc->p_pid +#define LINUX_DTRACE linuxulator32 #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_LINUX); Modified: head/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- head/sys/amd64/linux32/linux32_dummy.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/amd64/linux32/linux32_dummy.c Sat May 5 19:42:38 2012 (r235063) @@ -29,14 +29,23 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" +#include "opt_kdtrace.h" + #include +#include +#include #include #include #include #include +#include #include +/* DTrace init */ +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); + DUMMY(stime); DUMMY(olduname); DUMMY(syslog); Added: head/sys/compat/linux/check_error.d ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/compat/linux/check_error.d Sat May 5 19:42:38 2012 (r235063) @@ -0,0 +1,144 @@ +#!/usr/sbin/dtrace -qs + +/*- + * Copyright (c) 2008-2012 Alexander Leidinger + * 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 + * in this position and unchanged. + * 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 ``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 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$ + */ + +/* + * Report error conditions: + * - emulation errors (unsupportet stuff, unknown stuff, ...) + * - kernel errors (resource shortage, ...) + * - programming errors (errors which can happen, but should not happen) + */ + +linuxulator*:dummy::not_implemented, +linuxulator*:emul:proc_exit:child_clear_tid_error, +linuxulator*:emul:proc_exit:futex_failed, +linuxulator*:emul:linux_schedtail:copyout_error, +linuxulator*:futex:futex_get:error, +linuxulator*:futex:futex_sleep:requeue_error, +linuxulator*:futex:futex_sleep:sleep_error, +linuxulator*:futex:futex_wait:copyin_error, +linuxulator*:futex:futex_wait:itimerfix_error, +linuxulator*:futex:futex_wait:sleep_error, +linuxulator*:futex:futex_atomic_op:missing_access_check, +linuxulator*:futex:futex_atomic_op:unimplemented_op, +linuxulator*:futex:futex_atomic_op:unimplemented_cmp, +linuxulator*:futex:linux_sys_futex:unimplemented_clockswitch, +linuxulator*:futex:linux_sys_futex:copyin_error, +linuxulator*:futex:linux_sys_futex:unhandled_efault, +linuxulator*:futex:linux_sys_futex:unimplemented_lock_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_unlock_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_trylock_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_wait_requeue_pi, +linuxulator*:futex:linux_sys_futex:unimplemented_cmp_requeue_pi, +linuxulator*:futex:linux_sys_futex:unknown_operation, +linuxulator*:futex:linux_get_robust_list:copyout_error, +linuxulator*:futex:handle_futex_death:copyin_error, +linuxulator*:futex:fetch_robust_entry:copyin_error, +linuxulator*:futex:release_futexes:copyin_error, +linuxulator*:time:linux_clock_gettime:conversion_error, +linuxulator*:time:linux_clock_gettime:gettime_error, +linuxulator*:time:linux_clock_gettime:copyout_error, +linuxulator*:time:linux_clock_settime:conversion_error, +linuxulator*:time:linux_clock_settime:settime_error, +linuxulator*:time:linux_clock_settime:copyin_error, +linuxulator*:time:linux_clock_getres:conversion_error, +linuxulator*:time:linux_clock_getres:getres_error, +linuxulator*:time:linux_clock_getres:copyout_error, +linuxulator*:time:linux_nanosleep:conversion_error, +linuxulator*:time:linux_nanosleep:nanosleep_error, +linuxulator*:time:linux_nanosleep:copyout_error, +linuxulator*:time:linux_nanosleep:copyin_error, +linuxulator*:time:linux_clock_nanosleep:copyin_error, +linuxulator*:time:linux_clock_nanosleep:conversion_error, +linuxulator*:time:linux_clock_nanosleep:copyout_error, +linuxulator*:time:linux_clock_nanosleep:nanosleep_error, +linuxulator*:sysctl:handle_string:copyout_error, +linuxulator*:sysctl:linux_sysctl:copyin_error, +linuxulator*:mib:linux_sysctl_osname:sysctl_string_error, +linuxulator*:mib:linux_sysctl_osrelease:sysctl_string_error, +linuxulator*:mib:linux_sysctl_oss_version:sysctl_string_error, +linuxulator*:mib:linux_prison_create:vfs_copyopt_error, +linuxulator*:mib:linux_prison_check:vfs_copyopt_error, +linuxulator*:mib:linux_prison_check:vfs_getopt_error, +linuxulator*:mib:linux_prison_set:vfs_copyopt_error, +linuxulator*:mib:linux_prison_set:vfs_getopt_error, +linuxulator*:mib:linux_prison_get:vfs_setopt_error, +linuxulator*:mib:linux_prison_get:vfs_setopts_error +{ + printf("ERROR: %s in %s:%s:%s\n", probename, probeprov, probemod, probefunc); + stack(); + ustack(); +} + +linuxulator*:util:linux_driver_get_name_dev:nullcall, +linuxulator*:util:linux_driver_get_major_minor:nullcall, +linuxulator*:futex:linux_sys_futex:invalid_cmp_requeue_use, +linuxulator*:futex:linux_sys_futex:deprecated_requeue, +linuxulator*:futex:linux_set_robust_list:size_error, +linuxulator*:time:linux_clock_getres:nullcall +{ + printf("WARNING: %s:%s:%s:%s in application %s, maybe an application error?\n", probename, probeprov, probemod, probefunc, execname); + stack(); + ustack(); +} + +linuxulator*:util:linux_driver_get_major_minor:notfound +{ + printf("WARNING: Application %s failed to find %s in %s:%s:%s, this may or may not be a problem.\n", execname, stringof(args[0]), probename, probeprov, probemod); + stack(); + ustack(); +} + +linuxulator*:time:linux_to_native_clockid:unknown_clockid +{ + printf("INFO: Application %s tried to use unknown clockid %d. Please report this to freebsd-emulation@FreeBSD.org.\n", execname, arg0); +} + +linuxulator*:time:linux_to_native_clockid:unsupported_clockid, +linuxulator*:time:linux_clock_nanosleep:unsupported_clockid +{ + printf("WARNING: Application %s tried to use unsupported clockid (%d), this may or may not be a problem for the application.\nPatches to support this clockid are welcome on the freebsd-emulation@FreeBSD.org mailinglist.\n", execname, arg0); +} + +linuxulator*:time:linux_clock_nanosleep:unsupported_flags +{ + printf("WARNING: Application %s tried to use unsupported flags (%d), this may or may not be a problem for the application.\nPatches to support those flags are welcome on the freebsd-emulation@FreeBSD.org mailinglist.\n", execname, arg0); +} + +linuxulator*:sysctl:linux_sysctl:wrong_length +{ + printf("ERROR: Application %s issued a sysctl which failed the length restrictions.\nThe length passed is %d, the min length supported is 1 and the max length supported is %d.\n", execname, arg0, arg1); + stack(); + ustack(); +} + +linuxulator*:sysctl:linux_sysctl:unsupported_sysctl +{ + printf("ERROR: Application %s issued an unsupported sysctl (%s).\nPatches to support this sysctl are welcome on the freebsd-emulation@FreeBSD.org mailinglist.\n", execname, stringof(args[0])); +} Added: head/sys/compat/linux/check_internal_locks.d ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/compat/linux/check_internal_locks.d Sat May 5 19:42:38 2012 (r235063) @@ -0,0 +1,132 @@ +#!/usr/sbin/dtrace -qs + +/*- + * Copyright (c) 2008-2012 Alexander Leidinger + * 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 + * in this position and unchanged. + * 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 ``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 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$ + */ + +/** + * Check if the internal locks are correctly acquired/released: + * - no recursive locking (mtx locks, write locks) + * - no unlocking of already unlocked one + * + * Print stacktrace if a lock is longer locked than about 10sec or more. + */ + +#pragma D option dynvarsize=32m +#pragma D option specsize=32m + +BEGIN +{ + check["emul_lock"] = 0; + check["emul_shared_rlock"] = 0; + check["emul_shared_wlock"] = 0; + check["futex_mtx"] = 0; +} + +linuxulator*:locks:emul_lock:locked, +linuxulator*:locks:emul_shared_wlock:locked, +linuxulator*:locks:futex_mtx:locked +/check[probefunc] > 0/ +{ + printf("ERROR: recursive lock of %s (%p),", probefunc, arg0); + printf(" or missing SDT probe in kernel. Stack trace follows:"); + stack(); +} + +linuxulator*:locks:emul_lock:locked, +linuxulator*:locks:emul_shared_rlock:locked, +linuxulator*:locks:emul_shared_wlock:locked, +linuxulator*:locks:futex_mtx:locked +{ + ++check[probefunc]; + @stats[probefunc] = count(); + + ts[probefunc] = timestamp; + spec[probefunc] = speculation(); +} + +linuxulator*:locks:emul_lock:unlock, +linuxulator*:locks:emul_shared_rlock:unlock, +linuxulator*:locks:emul_shared_wlock:unlock, +linuxulator*:locks:futex_mtx:unlock +/check[probefunc] == 0/ +{ + printf("ERROR: unlock attemt of unlocked %s (%p),", probefunc, arg0); + printf(" missing SDT probe in kernel, or dtrace program started"); + printf(" while the %s was already held (race condition).", probefunc); + printf(" Stack trace follows:"); + stack(); +} + +linuxulator*:locks:emul_lock:unlock, +linuxulator*:locks:emul_shared_rlock:unlock, +linuxulator*:locks:emul_shared_wlock:unlock, +linuxulator*:locks:futex_mtx:unlock +{ + discard(spec[probefunc]); + spec[probefunc] = 0; + --check[probefunc]; +} + +/* Timeout handling */ + +tick-10s +/spec["emul_lock"] != 0 && timestamp - ts["emul_lock"] >= 9999999000/ +{ + commit(spec["emul_lock"]); + spec["emul_lock"] = 0; +} + +tick-10s +/spec["emul_shared_wlock"] != 0 && timestamp - ts["emul_shared_wlock"] >= 9999999000/ +{ + commit(spec["emul_shared_wlock"]); + spec["emul_shared_wlock"] = 0; +} + +tick-10s +/spec["emul_shared_rlock"] != 0 && timestamp - ts["emul_shared_rlock"] >= 9999999000/ +{ + commit(spec["emul_shared_rlock"]); + spec["emul_shared_rlock"] = 0; +} + +tick-10s +/spec["futex_mtx"] != 0 && timestamp - ts["futex_mtx"] >= 9999999000/ +{ + commit(spec["futex_mtx"]); + spec["futex_mtx"] = 0; +} + + +/* Statistics */ + +END +{ + printf("Number of locks per type:"); + printa(@stats); +} Added: head/sys/compat/linux/linux_dtrace.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/compat/linux/linux_dtrace.h Sat May 5 19:42:38 2012 (r235063) @@ -0,0 +1,95 @@ +/*- + * Copyright (c) 2008-2012 Alexander Leidinger + * 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 + * in this position and unchanged. + * 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 ``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 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$ + */ + +#ifndef _LINUX_DTRACE_H_ +#define _LINUX_DTRACE_H_ + +/** + * DTrace support macros for the linuxulator. + * + * Some wrapper macros to make it more easy to handle the linuxulator + * providers and to allow to make the name depend upon the bitsize. + * + * Basically this is the same as the normal SDT macros in sys/sdt.h. The + * difference is that the provider name is automatically inserted, and + * we do not use a different name for the probe-description. + */ + +#define LIN_SDT_PROVIDER_DEFINE(x) SDT_PROVIDER_DEFINE(x) +#define LIN_SDT_PROVIDER_DECLARE(x) SDT_PROVIDER_DECLARE(x) + +#define _LIN_SDT_PROBE_DECLARE(a, b, c, d) SDT_PROBE_DECLARE(a, b, c, d) +#define LIN_SDT_PROBE_DECLARE(a, b, c) _LIN_SDT_PROBE_DECLARE( \ + LINUX_DTRACE, a, b, c) + +#define _LIN_SDT_PROBE_DEFINE0(a, b, c, d) SDT_PROBE_DEFINE(a, \ + b, c, d, d) +#define LIN_SDT_PROBE_DEFINE0(a, b, c) _LIN_SDT_PROBE_DEFINE0(\ + LINUX_DTRACE, a, b, c) +#define _LIN_SDT_PROBE_DEFINE1(a, b, c, d, e) SDT_PROBE_DEFINE1(a, \ + b, c, d, d, e) +#define LIN_SDT_PROBE_DEFINE1(a, b, c, d) _LIN_SDT_PROBE_DEFINE1(\ + LINUX_DTRACE, a, b, c, d) +#define _LIN_SDT_PROBE_DEFINE2(a, b, c, d, e, f) SDT_PROBE_DEFINE2(a, \ + b, c, d, d, e, f) +#define LIN_SDT_PROBE_DEFINE2(a, b, c, d, e) _LIN_SDT_PROBE_DEFINE2(\ + LINUX_DTRACE, a, b, c, d, e) +#define _LIN_SDT_PROBE_DEFINE3(a, b, c, d, e, f, g) SDT_PROBE_DEFINE3(a, \ + b, c, d, d, e, f, g) +#define LIN_SDT_PROBE_DEFINE3(a, b, c, d, e, f) _LIN_SDT_PROBE_DEFINE3(\ + LINUX_DTRACE, a, b, c, d, e, f) +#define _LIN_SDT_PROBE_DEFINE4(a, b, c, d, e, f, g, h) SDT_PROBE_DEFINE4(a, \ + b, c, d, d, e, f, g, h) +#define LIN_SDT_PROBE_DEFINE4(a, b, c, d, e, f, g) _LIN_SDT_PROBE_DEFINE4(\ + LINUX_DTRACE, a, b, c, d, e, f, g) +#define _LIN_SDT_PROBE_DEFINE5(a, b, c, d, e, f, g, h, i) \ + SDT_PROBE_DEFINE5(a, b, c, d, d, e, f, g, h, i) +#define LIN_SDT_PROBE_DEFINE5(a, b, c, d, e, f, g, h) _LIN_SDT_PROBE_DEFINE5(\ + LINUX_DTRACE, a, b, c, d, e, f, g, h) + +#define _LIN_SDT_PROBE_ARGTYPE(a, b, c, d, e, f) SDT_PROBE_ARGTYPE(a, b,\ + c, d, e, f) +#define LIN_SDT_PROBE_ARGTYPE(a, b, c, d, e) _LIN_SDT_PROBE_ARGTYPE( \ + LINUX_DTRACE, a, b, c, d, e) + +#define LIN_SDT_PROBE0(a, b, c) SDT_PROBE1(LINUX_DTRACE, a, b, \ + c, 0) +#define LIN_SDT_PROBE1(a, b, c, d) SDT_PROBE1(LINUX_DTRACE, a, b, \ + c, d) +#define LIN_SDT_PROBE2(a, b, c, d, e) SDT_PROBE2(LINUX_DTRACE, a, b, \ + c, d, e) +#define LIN_SDT_PROBE3(a, b, c, d, e, f) SDT_PROBE3(LINUX_DTRACE, a, b, \ + c, d, e, f) +#define LIN_SDT_PROBE4(a, b, c, d, e, f, g) SDT_PROBE4(LINUX_DTRACE, a, b, \ + c, d, e, f, g) +#define _LIN_SDT_PROBE5(a, b, c, d, e, f, g, h, i) SDT_PROBE(a, b, c, d, \ + e, f, g, h, i) +#define LIN_SDT_PROBE5(a, b, c, d, e, f, g, h) _LIN_SDT_PROBE5(LINUX_DTRACE, \ + a, b, c, d, e, f, g, h) + +#endif /* _LINUX_DTRACE_H_ */ Modified: head/sys/compat/linux/linux_emul.c ============================================================================== --- head/sys/compat/linux/linux_emul.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_emul.c Sat May 5 19:42:38 2012 (r235063) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#include "opt_kdtrace.h" #include #include @@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -53,9 +55,64 @@ __FBSDID("$FreeBSD$"); #include #endif +#include #include #include +/** + * Special DTrace provider for the linuxulator. + * + * In this file we define the provider for the entire linuxulator. All + * modules (= files of the linuxulator) use it. + * + * We define a different name depending on the emulated bitsize, see + * ../..//linux{,32}/linux.h, e.g.: + * native bitsize = linuxulator + * amd64, 32bit emulation = linuxulator32 + */ +LIN_SDT_PROVIDER_DEFINE(LINUX_DTRACE); + +/** + * Special DTrace module "locks", it covers some linuxulator internal + * locks. + */ +LIN_SDT_PROBE_DEFINE1(locks, emul_lock, locked, "struct mtx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_lock, unlock, "struct mtx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_rlock, locked, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_rlock, unlock, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_wlock, locked, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(locks, emul_shared_wlock, unlock, "struct sx *"); + +/** + * DTrace probes in this module. + */ +LIN_SDT_PROBE_DEFINE2(emul, em_find, entry, "struct proc *", "int"); +LIN_SDT_PROBE_DEFINE0(emul, em_find, return); +LIN_SDT_PROBE_DEFINE3(emul, proc_init, entry, "struct thread *", "pid_t", + "int"); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, create_thread); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, fork); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, exec); +LIN_SDT_PROBE_DEFINE0(emul, proc_init, return); +LIN_SDT_PROBE_DEFINE1(emul, proc_exit, entry, "struct proc *"); +LIN_SDT_PROBE_DEFINE0(emul, proc_exit, futex_failed); +LIN_SDT_PROBE_DEFINE3(emul, proc_exit, reparent, "pid_t", "pid_t", + "struct proc *"); +LIN_SDT_PROBE_DEFINE1(emul, proc_exit, child_clear_tid_error, "int"); +LIN_SDT_PROBE_DEFINE0(emul, proc_exit, return); +LIN_SDT_PROBE_DEFINE2(emul, proc_exec, entry, "struct proc *", + "struct image_params *"); +LIN_SDT_PROBE_DEFINE0(emul, proc_exec, return); +LIN_SDT_PROBE_DEFINE0(emul, linux_schedtail, entry); +LIN_SDT_PROBE_DEFINE1(emul, linux_schedtail, copyout_error, "int"); +LIN_SDT_PROBE_DEFINE0(emul, linux_schedtail, return); +LIN_SDT_PROBE_DEFINE1(emul, linux_set_tid_address, entry, "int *"); +LIN_SDT_PROBE_DEFINE0(emul, linux_set_tid_address, return); +LIN_SDT_PROBE_DEFINE2(emul, linux_kill_threads, entry, "struct thread *", + "int"); +LIN_SDT_PROBE_DEFINE1(emul, linux_kill_threads, kill, "pid_t"); +LIN_SDT_PROBE_DEFINE0(emul, linux_kill_threads, return); + struct sx emul_shared_lock; struct mtx emul_lock; @@ -65,6 +122,8 @@ em_find(struct proc *p, int locked) { struct linux_emuldata *em; + LIN_SDT_PROBE2(emul, em_find, entry, p, locked); + if (locked == EMUL_DOLOCK) EMUL_LOCK(&emul_lock); @@ -73,6 +132,7 @@ em_find(struct proc *p, int locked) if (em == NULL && locked == EMUL_DOLOCK) EMUL_UNLOCK(&emul_lock); + LIN_SDT_PROBE1(emul, em_find, return, em); return (em); } @@ -82,8 +142,10 @@ linux_proc_init(struct thread *td, pid_t struct linux_emuldata *em, *p_em; struct proc *p; + LIN_SDT_PROBE3(emul, proc_init, entry, td, child, flags); + if (child != 0) { - /* non-exec call */ + /* fork or create a thread */ em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO); em->pid = child; em->pdeath_signal = 0; @@ -91,9 +153,12 @@ linux_proc_init(struct thread *td, pid_t em->robust_futexes = NULL; if (flags & LINUX_CLONE_THREAD) { /* handled later in the code */ + LIN_SDT_PROBE0(emul, proc_init, create_thread); } else { struct linux_emuldata_shared *s; + LIN_SDT_PROBE0(emul, proc_init, fork); + s = malloc(sizeof *s, M_LINUX, M_WAITOK | M_ZERO); s->refs = 1; s->group_pid = child; @@ -102,6 +167,9 @@ linux_proc_init(struct thread *td, pid_t em->shared = s; } } else { + /* exec */ + LIN_SDT_PROBE0(emul, proc_init, exec); + /* lookup the old one */ em = em_find(td->td_proc, EMUL_DOLOCK); KASSERT(em != NULL, ("proc_init: emuldata not found in exec case.\n")); @@ -136,8 +204,7 @@ linux_proc_init(struct thread *td, pid_t * rwlock held */ } - } - if (child != 0) { + EMUL_SHARED_WLOCK(&emul_shared_lock); LIST_INSERT_HEAD(&em->shared->threads, em, threads); EMUL_SHARED_WUNLOCK(&emul_shared_lock); @@ -149,6 +216,7 @@ linux_proc_init(struct thread *td, pid_t } else EMUL_UNLOCK(&emul_lock); + LIN_SDT_PROBE0(emul, proc_init, return); return (0); } @@ -164,6 +232,8 @@ linux_proc_exit(void *arg __unused, stru if (__predict_true(p->p_sysent != &elf_linux_sysvec)) return; + LIN_SDT_PROBE1(emul, proc_exit, entry, p); + release_futexes(p); /* find the emuldata */ @@ -173,6 +243,9 @@ linux_proc_exit(void *arg __unused, stru /* reparent all procs that are not a thread leader to initproc */ if (em->shared->group_pid != p->p_pid) { + LIN_SDT_PROBE3(emul, proc_exit, reparent, + em->shared->group_pid, p->p_pid, p); + child_clear_tid = em->child_clear_tid; EMUL_UNLOCK(&emul_lock); sx_xlock(&proctree_lock); @@ -208,7 +281,12 @@ linux_proc_exit(void *arg __unused, stru error = copyout(&null, child_clear_tid, sizeof(null)); if (error) { + LIN_SDT_PROBE1(emul, proc_exit, + child_clear_tid_error, error); + free(em, M_LINUX); + + LIN_SDT_PROBE0(emul, proc_exit, return); return; } @@ -224,8 +302,10 @@ linux_proc_exit(void *arg __unused, stru * this cannot happen at the moment and if this happens it * probably means there is a user space bug */ - if (error) + if (error) { + LIN_SDT_PROBE0(emul, proc_exit, futex_failed); printf(LMSG("futex stuff in proc_exit failed.\n")); + } } /* clean the stuff up */ @@ -250,6 +330,8 @@ linux_proc_exit(void *arg __unused, stru EMUL_UNLOCK(&emul_lock); } sx_xunlock(&proctree_lock); + + LIN_SDT_PROBE0(emul, proc_exit, return); } /* @@ -260,6 +342,9 @@ linux_proc_exit(void *arg __unused, stru void linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp) { + if (__predict_false(imgp->sysent == &elf_linux_sysvec)) { + LIN_SDT_PROBE2(emul, proc_exec, entry, p, imgp); + } if (__predict_false(imgp->sysent == &elf_linux_sysvec && p->p_sysent != &elf_linux_sysvec)) linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0); @@ -297,6 +382,10 @@ linux_proc_exec(void *arg __unused, stru free(em, M_LINUX); } + + if (__predict_false(imgp->sysent == &elf_linux_sysvec)) { + LIN_SDT_PROBE0(emul, proc_exec, return); + } } void @@ -309,6 +398,8 @@ linux_schedtail(struct thread *td) p = td->td_proc; + LIN_SDT_PROBE1(emul, linux_schedtail, entry, p); + /* find the emuldata */ em = em_find(p, EMUL_DOLOCK); @@ -316,10 +407,18 @@ linux_schedtail(struct thread *td) child_set_tid = em->child_set_tid; EMUL_UNLOCK(&emul_lock); - if (child_set_tid != NULL) + if (child_set_tid != NULL) { error = copyout(&p->p_pid, (int *)child_set_tid, sizeof(p->p_pid)); + if (error != 0) { + LIN_SDT_PROBE1(emul, linux_schedtail, copyout_error, + error); + } + } + + LIN_SDT_PROBE0(emul, linux_schedtail, return); + return; } @@ -328,10 +427,7 @@ linux_set_tid_address(struct thread *td, { struct linux_emuldata *em; -#ifdef DEBUG - if (ldebug(set_tid_address)) - printf(ARGS(set_tid_address, "%p"), args->tidptr); -#endif + LIN_SDT_PROBE1(emul, linux_set_tid_address, entry, args->tidptr); /* find the emuldata */ em = em_find(td->td_proc, EMUL_DOLOCK); @@ -342,6 +438,8 @@ linux_set_tid_address(struct thread *td, td->td_retval[0] = td->td_proc->p_pid; EMUL_UNLOCK(&emul_lock); + + LIN_SDT_PROBE0(emul, linux_set_tid_address, return); return 0; } @@ -351,6 +449,8 @@ linux_kill_threads(struct thread *td, in struct linux_emuldata *em, *td_em, *tmp_em; struct proc *sp; + LIN_SDT_PROBE2(emul, linux_kill_threads, entry, td, sig); + td_em = em_find(td->td_proc, EMUL_DONTLOCK); KASSERT(td_em != NULL, ("linux_kill_threads: emuldata not found.\n")); @@ -364,9 +464,10 @@ linux_kill_threads(struct thread *td, in if ((sp->p_flag & P_WEXIT) == 0) kern_psignal(sp, sig); PROC_UNLOCK(sp); -#ifdef DEBUG - printf(LMSG("linux_kill_threads: kill PID %d\n"), em->pid); -#endif + + LIN_SDT_PROBE1(emul, linux_kill_threads, kill, em->pid); } EMUL_SHARED_RUNLOCK(&emul_shared_lock); + + LIN_SDT_PROBE0(emul, linux_kill_threads, return); } Modified: head/sys/compat/linux/linux_emul.h ============================================================================== --- head/sys/compat/linux/linux_emul.h Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_emul.h Sat May 5 19:42:38 2012 (r235063) @@ -64,13 +64,42 @@ struct linux_emuldata { struct linux_emuldata *em_find(struct proc *, int locked); -#define EMUL_LOCK(l) mtx_lock(l) -#define EMUL_UNLOCK(l) mtx_unlock(l) - -#define EMUL_SHARED_RLOCK(l) sx_slock(l) -#define EMUL_SHARED_RUNLOCK(l) sx_sunlock(l) -#define EMUL_SHARED_WLOCK(l) sx_xlock(l) -#define EMUL_SHARED_WUNLOCK(l) sx_xunlock(l) +/* + * DTrace probes for locks should be fired after locking and before releasing + * to prevent races (to provide data/function stability in dtrace, see the + * output of "dtrace -v ..." and the corresponding dtrace docs). + */ +#define EMUL_LOCK(l) do { \ + mtx_lock(l); \ + LIN_SDT_PROBE1(locks, emul_lock, \ + locked, l); \ + } while (0) +#define EMUL_UNLOCK(l) do { \ + LIN_SDT_PROBE1(locks, emul_lock, \ + unlock, l); \ + mtx_unlock(l); \ + } while (0) + +#define EMUL_SHARED_RLOCK(l) do { \ + sx_slock(l); \ + LIN_SDT_PROBE1(locks, emul_shared_rlock, \ + locked, l); \ + } while (0) +#define EMUL_SHARED_RUNLOCK(l) do { \ + LIN_SDT_PROBE1(locks, emul_shared_rlock, \ + unlock, l); \ + sx_sunlock(l); \ + } while (0) +#define EMUL_SHARED_WLOCK(l) do { \ + sx_xlock(l); \ + LIN_SDT_PROBE1(locks, emul_shared_wlock, \ + locked, l); \ + } while (0) +#define EMUL_SHARED_WUNLOCK(l) do { \ + LIN_SDT_PROBE1(locks, emul_shared_wlock, \ + unlock, l); \ + sx_xunlock(l); \ + } while (0) /* for em_find use */ #define EMUL_DOLOCK 1 Modified: head/sys/compat/linux/linux_fork.c ============================================================================== --- head/sys/compat/linux/linux_fork.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_fork.c Sat May 5 19:42:38 2012 (r235063) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" +#include "opt_kdtrace.h" #include #include @@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -48,9 +50,17 @@ __FBSDID("$FreeBSD$"); #include #include #endif +#include #include #include +/* DTrace init */ +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); + +/* Linuxulator-global DTrace probes */ +LIN_SDT_PROBE_DECLARE(locks, emul_lock, locked); +LIN_SDT_PROBE_DECLARE(locks, emul_lock, unlock); + int linux_fork(struct thread *td, struct linux_fork_args *args) Modified: head/sys/compat/linux/linux_futex.c ============================================================================== --- head/sys/compat/linux/linux_futex.c Sat May 5 17:20:12 2012 (r235062) +++ head/sys/compat/linux/linux_futex.c Sat May 5 19:42:38 2012 (r235063) @@ -38,6 +38,7 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. #endif #include "opt_compat.h" +#include "opt_kdtrace.h" #include #include @@ -51,6 +52,7 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. #include #include #include +#include #include #include @@ -61,10 +63,131 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. #include #include #endif +#include #include #include #include +/* DTrace init */ +LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); + +/* Linuxulator-global DTrace probes */ +LIN_SDT_PROBE_DECLARE(locks, emul_lock, locked); +LIN_SDT_PROBE_DECLARE(locks, emul_lock, unlock); + +/** + * Futex part for the special DTrace module "locks". + */ +LIN_SDT_PROBE_DEFINE1(locks, futex_mtx, locked, "struct mtx *"); +LIN_SDT_PROBE_DEFINE1(locks, futex_mtx, unlock, "struct mtx *"); + +/** + * Per futex probes. + */ +LIN_SDT_PROBE_DEFINE1(futex, futex, create, "struct sx *"); +LIN_SDT_PROBE_DEFINE1(futex, futex, destroy, "struct sx *"); + +/** + * DTrace probes in this module. + */ +LIN_SDT_PROBE_DEFINE2(futex, futex_put, entry, "struct futex *", + "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE3(futex, futex_put, destroy, "uint32_t *", "uint32_t", + "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_put, unlock, "uint32_t *", "uint32_t", + "int"); +LIN_SDT_PROBE_DEFINE0(futex, futex_put, return); +LIN_SDT_PROBE_DEFINE3(futex, futex_get0, entry, "uint32_t *", "struct futex **", + "uint32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_get0, umtx_key_get_error, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_get0, shared, "uint32_t *", "uint32_t", + "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_get0, null, "uint32_t *"); +LIN_SDT_PROBE_DEFINE3(futex, futex_get0, new, "uint32_t *", "uint32_t", "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_get0, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_get, entry, "uint32_t *", + "struct waiting_proc **", "struct futex **"); +LIN_SDT_PROBE_DEFINE0(futex, futex_get, error); +LIN_SDT_PROBE_DEFINE1(futex, futex_get, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_sleep, entry, "struct futex *", + "struct waiting_proc **", "int"); +LIN_SDT_PROBE_DEFINE5(futex, futex_sleep, requeue_error, "int", "uint32_t *", + "struct waiting_proc *", "uint32_t *", "uint32_t"); +LIN_SDT_PROBE_DEFINE3(futex, futex_sleep, sleep_error, "int", "uint32_t *", + "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE1(futex, futex_sleep, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_wake, entry, "struct futex *", "int", + "uint32_t"); +LIN_SDT_PROBE_DEFINE3(futex, futex_wake, iterate, "uint32_t", + "struct waiting_proc *", "uin32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wake, wakeup, "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wake, return, "int"); +LIN_SDT_PROBE_DEFINE4(futex, futex_requeue, entry, "struct futex *", "int", + "struct futex *", "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_requeue, wakeup, "struct waiting_proc *"); +LIN_SDT_PROBE_DEFINE3(futex, futex_requeue, requeue, "uint32_t *", + "struct waiting_proc *", "uint32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_requeue, return, "int"); +LIN_SDT_PROBE_DEFINE4(futex, futex_wait, entry, "struct futex *", + "struct waiting_proc **", "struct l_timespec *", "uint32_t"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, itimerfix_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, sleep_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, futex_atomic_op, entry, "struct thread *", + "int", "uint32_t"); +LIN_SDT_PROBE_DEFINE4(futex, futex_atomic_op, decoded_op, "int", "int", "int", + "int"); +LIN_SDT_PROBE_DEFINE0(futex, futex_atomic_op, missing_access_check); +LIN_SDT_PROBE_DEFINE1(futex, futex_atomic_op, unimplemented_op, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_atomic_op, unimplemented_cmp, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_atomic_op, return, "int"); +LIN_SDT_PROBE_DEFINE2(futex, linux_sys_futex, entry, "struct thread *", + "struct linux_sys_futex_args *"); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_clockswitch); +LIN_SDT_PROBE_DEFINE1(futex, linux_sys_futex, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, invalid_cmp_requeue_use); +LIN_SDT_PROBE_DEFINE3(futex, linux_sys_futex, debug_wait, "uint32_t *", + "uint32_t", "uint32_t"); +LIN_SDT_PROBE_DEFINE4(futex, linux_sys_futex, debug_wait_value_neq, + "uint32_t *", "uint32_t", "int", "uint32_t"); +LIN_SDT_PROBE_DEFINE3(futex, linux_sys_futex, debug_wake, "uint32_t *", + "uint32_t", "uint32_t"); +LIN_SDT_PROBE_DEFINE5(futex, linux_sys_futex, debug_cmp_requeue, "uint32_t *", + "uint32_t", "uint32_t", "uint32_t *", "struct l_timespec *"); +LIN_SDT_PROBE_DEFINE2(futex, linux_sys_futex, debug_cmp_requeue_value_neq, + "uint32_t", "int"); +LIN_SDT_PROBE_DEFINE5(futex, linux_sys_futex, debug_wake_op, "uint32_t *", + "int", "uint32_t", "uint32_t *", "uint32_t"); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unhandled_efault); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_lock_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_unlock_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_trylock_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, deprecated_requeue); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_wait_requeue_pi); +LIN_SDT_PROBE_DEFINE0(futex, linux_sys_futex, unimplemented_cmp_requeue_pi); +LIN_SDT_PROBE_DEFINE1(futex, linux_sys_futex, unknown_operation, "int"); +LIN_SDT_PROBE_DEFINE1(futex, linux_sys_futex, return, "int"); +LIN_SDT_PROBE_DEFINE2(futex, linux_set_robust_list, entry, "struct thread *", + "struct linux_set_robust_list_args *"); +LIN_SDT_PROBE_DEFINE0(futex, linux_set_robust_list, size_error); +LIN_SDT_PROBE_DEFINE1(futex, linux_set_robust_list, return, "int"); +LIN_SDT_PROBE_DEFINE2(futex, linux_get_robust_list, entry, "struct thread *", + "struct linux_get_robust_list_args *"); +LIN_SDT_PROBE_DEFINE1(futex, linux_get_robust_list, copyout_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, linux_get_robust_list, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, handle_futex_death, entry, "struct proc *", + "uint32_t *", "int"); +LIN_SDT_PROBE_DEFINE1(futex, handle_futex_death, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, handle_futex_death, return, "int"); +LIN_SDT_PROBE_DEFINE3(futex, fetch_robust_entry, entry, + "struct linux_robust_list **", "struct linux_robust_list **", "int *"); +LIN_SDT_PROBE_DEFINE1(futex, fetch_robust_entry, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, fetch_robust_entry, return, "int"); +LIN_SDT_PROBE_DEFINE1(futex, release_futexes, entry, "struct proc *"); +LIN_SDT_PROBE_DEFINE1(futex, release_futexes, copyin_error, "int"); +LIN_SDT_PROBE_DEFINE0(futex, release_futexes, return); + static MALLOC_DEFINE(M_FUTEX, "futex", "Linux futexes"); static MALLOC_DEFINE(M_FUTEX_WP, "futex wp", "Linux futexes wp"); @@ -90,13 +213,30 @@ struct futex_list futex_list; #define FUTEX_LOCK(f) sx_xlock(&(f)->f_lck) #define FUTEX_UNLOCK(f) sx_xunlock(&(f)->f_lck) -#define FUTEX_INIT(f) sx_init_flags(&(f)->f_lck, "ftlk", SX_DUPOK) -#define FUTEX_DESTROY(f) sx_destroy(&(f)->f_lck) +#define FUTEX_INIT(f) do { \ + sx_init_flags(&(f)->f_lck, "ftlk", \ + SX_DUPOK); \ + LIN_SDT_PROBE1(futex, futex, create, \ + &(f)->f_lck); \ + } while (0) +#define FUTEX_DESTROY(f) do { \ + LIN_SDT_PROBE1(futex, futex, destroy, \ + &(f)->f_lck); \ + sx_destroy(&(f)->f_lck); \ + } while (0) #define FUTEX_ASSERT_LOCKED(f) sx_assert(&(f)->f_lck, SA_XLOCKED) struct mtx futex_mtx; /* protects the futex list */ -#define FUTEXES_LOCK mtx_lock(&futex_mtx) -#define FUTEXES_UNLOCK mtx_unlock(&futex_mtx) +#define FUTEXES_LOCK do { \ + mtx_lock(&futex_mtx); \ + LIN_SDT_PROBE1(locks, futex_mtx, \ + locked, &futex_mtx); \ + } while (0) +#define FUTEXES_UNLOCK do { \ + LIN_SDT_PROBE1(locks, futex_mtx, \ + unlock, &futex_mtx); \ + mtx_unlock(&futex_mtx); \ + } while (0) /* flags for futex_get() */ #define FUTEX_CREATE_WP 0x1 /* create waiting_proc */ @@ -123,6 +263,7 @@ int futex_xorl(int oparg, uint32_t *uadd static void futex_put(struct futex *f, struct waiting_proc *wp) { + LIN_SDT_PROBE2(futex, futex_put, entry, f, wp); FUTEX_ASSERT_LOCKED(f); if (wp != NULL) { @@ -137,18 +278,26 @@ futex_put(struct futex *f, struct waitin FUTEXES_UNLOCK; FUTEX_UNLOCK(f); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-head@FreeBSD.ORG Sat May 5 20:07:33 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DDAFB106566C; Sat, 5 May 2012 20:07:33 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C58AF8FC08; Sat, 5 May 2012 20:07:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45K7XXI073528; Sat, 5 May 2012 20:07:33 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45K7X4e073525; Sat, 5 May 2012 20:07:33 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205052007.q45K7X4e073525@svn.freebsd.org> From: Michael Tuexen Date: Sat, 5 May 2012 20:07:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235064 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 20:07:34 -0000 Author: tuexen Date: Sat May 5 20:07:33 2012 New Revision: 235064 URL: http://svn.freebsd.org/changeset/base/235064 Log: Honor SCTP_ENABLE_STREAM_RESET socket option when processing incoming requests. Fix also the provided result in the response and use names as specified in RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_header.h head/sys/netinet/sctp_input.c Modified: head/sys/netinet/sctp_header.h ============================================================================== --- head/sys/netinet/sctp_header.h Sat May 5 19:42:38 2012 (r235063) +++ head/sys/netinet/sctp_header.h Sat May 5 20:07:33 2012 (r235064) @@ -499,12 +499,13 @@ struct sctp_stream_reset_add_strm { uint16_t reserved; } SCTP_PACKED; -#define SCTP_STREAM_RESET_NOTHING 0x00000000 /* Nothing for me to do */ -#define SCTP_STREAM_RESET_PERFORMED 0x00000001 /* Did it */ -#define SCTP_STREAM_RESET_REJECT 0x00000002 /* refused to do it */ -#define SCTP_STREAM_RESET_ERROR_STR 0x00000003 /* bad Stream no */ -#define SCTP_STREAM_RESET_TRY_LATER 0x00000004 /* collision, try again */ -#define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005 /* bad str-reset seq no */ +#define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */ +#define SCTP_STREAM_RESET_RESULT_PERFORMED 0x00000001 +#define SCTP_STREAM_RESET_RESULT_DENIED 0x00000002 +#define SCTP_STREAM_RESET_RESULT_ERR__WRONG_SSN 0x00000003 /* XXX: unused */ +#define SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS 0x00000004 +#define SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO 0x00000005 +#define SCTP_STREAM_RESET_RESULT_IN_PROGRESS 0x00000006 /* XXX: unused */ /* * convience structures, note that if you are making a request for specific Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Sat May 5 19:42:38 2012 (r235063) +++ head/sys/netinet/sctp_input.c Sat May 5 20:07:33 2012 (r235064) @@ -3599,7 +3599,7 @@ sctp_handle_stream_reset_response(struct asoc->stream_reset_out_is_outstanding = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action == SCTP_STREAM_RESET_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* do it */ sctp_reset_out_streams(stcb, number_entries, srparam->list_of_streams); } else { @@ -3610,7 +3610,7 @@ sctp_handle_stream_reset_response(struct number_entries = (lparm_len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t); if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_PERFORMED) { + if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } @@ -3626,7 +3626,7 @@ sctp_handle_stream_reset_response(struct stcb->asoc.strm_pending_add_size = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action == SCTP_STREAM_RESET_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* Put the new streams into effect */ stcb->asoc.streamoutcnt += num_stream; sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); @@ -3637,7 +3637,7 @@ sctp_handle_stream_reset_response(struct } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_PERFORMED) { + if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, SCTP_STREAM_CHANGED_DENIED); } @@ -3655,7 +3655,7 @@ sctp_handle_stream_reset_response(struct /* huh ? */ return (0); } - if (action == SCTP_STREAM_RESET_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { resp = (struct sctp_stream_reset_response_tsn *)respin; asoc->stream_reset_outstanding--; fwdtsn.ch.chunk_length = htons(sizeof(struct sctp_forward_tsn_chunk)); @@ -3714,10 +3714,12 @@ sctp_handle_str_reset_request_in(struct seq = ntohl(req->request_seq); if (asoc->str_reset_seq_in == seq) { - if (trunc) { + asoc->last_reset_action[1] = asoc->last_reset_action[0]; + if (!(asoc->local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if (trunc) { /* Can't do it, since they exceeded our buffer size */ - asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } else if (stcb->asoc.stream_reset_out_is_outstanding == 0) { len = ntohs(req->ph.param_length); number_entries = ((len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t)); @@ -3725,9 +3727,7 @@ sctp_handle_str_reset_request_in(struct temp = ntohs(req->list_of_streams[i]); req->list_of_streams[i] = temp; } - /* move the reset action back one */ - asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; sctp_add_stream_reset_out(chk, number_entries, req->list_of_streams, asoc->str_reset_seq_out, seq, (asoc->sending_seq - 1)); @@ -3737,8 +3737,7 @@ sctp_handle_str_reset_request_in(struct stcb->asoc.stream_reset_outstanding++; } else { /* Can't do it, since we have sent one out */ - asoc->last_reset_action[1] = asoc->last_reset_action[0]; - asoc->last_reset_action[0] = SCTP_STREAM_RESET_TRY_LATER; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS; } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; @@ -3747,7 +3746,7 @@ sctp_handle_str_reset_request_in(struct } else if (asoc->str_reset_seq_in - 2 == seq) { sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -3769,7 +3768,13 @@ sctp_handle_str_reset_request_tsn(struct seq = ntohl(req->request_seq); if (asoc->str_reset_seq_in == seq) { - fwdtsn.ch.chunk_length = htons(sizeof(struct sctp_forward_tsn_chunk)); + if (!(asoc->local_strreset_support & SCTP_ENABLE_CHANGE_ASSOC_REQ)) { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; + + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else + fwdtsn.ch.chunk_length = htons(sizeof(struct sctp_forward_tsn_chunk)); fwdtsn.ch.chunk_type = SCTP_FORWARD_CUM_TSN; fwdtsn.ch.chunk_flags = 0; fwdtsn.new_cumulative_tsn = htonl(stcb->asoc.highest_tsn_inside_map + 1); @@ -3777,45 +3782,41 @@ sctp_handle_str_reset_request_tsn(struct if (abort_flag) { return (1); } - stcb->asoc.highest_tsn_inside_map += SCTP_STREAM_RESET_TSN_DELTA; + asoc->highest_tsn_inside_map += SCTP_STREAM_RESET_TSN_DELTA; if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MAP_LOGGING_ENABLE) { sctp_log_map(0, 10, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT); } - stcb->asoc.tsn_last_delivered = stcb->asoc.cumulative_tsn = stcb->asoc.highest_tsn_inside_map; - stcb->asoc.mapping_array_base_tsn = stcb->asoc.highest_tsn_inside_map + 1; - memset(stcb->asoc.mapping_array, 0, stcb->asoc.mapping_array_size); - stcb->asoc.highest_tsn_inside_nr_map = stcb->asoc.highest_tsn_inside_map; - memset(stcb->asoc.nr_mapping_array, 0, stcb->asoc.mapping_array_size); - atomic_add_int(&stcb->asoc.sending_seq, 1); + asoc->tsn_last_delivered = asoc->cumulative_tsn = asoc->highest_tsn_inside_map; + asoc->mapping_array_base_tsn = asoc->highest_tsn_inside_map + 1; + memset(asoc->mapping_array, 0, asoc->mapping_array_size); + asoc->highest_tsn_inside_nr_map = asoc->highest_tsn_inside_map; + memset(asoc->nr_mapping_array, 0, asoc->mapping_array_size); + atomic_add_int(&asoc->sending_seq, 1); /* save off historical data for retrans */ - stcb->asoc.last_sending_seq[1] = stcb->asoc.last_sending_seq[0]; - stcb->asoc.last_sending_seq[0] = stcb->asoc.sending_seq; - stcb->asoc.last_base_tsnsent[1] = stcb->asoc.last_base_tsnsent[0]; - stcb->asoc.last_base_tsnsent[0] = stcb->asoc.mapping_array_base_tsn; + asoc->last_sending_seq[1] = asoc->last_sending_seq[0]; + asoc->last_sending_seq[0] = asoc->sending_seq; + asoc->last_base_tsnsent[1] = asoc->last_base_tsnsent[0]; + asoc->last_base_tsnsent[0] = asoc->mapping_array_base_tsn; sctp_add_stream_reset_result_tsn(chk, ntohl(req->request_seq), - SCTP_STREAM_RESET_PERFORMED, - stcb->asoc.sending_seq, - stcb->asoc.mapping_array_base_tsn); + SCTP_STREAM_RESET_RESULT_PERFORMED, + asoc->sending_seq, + asoc->mapping_array_base_tsn); sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; - sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + asoc->last_reset_action[1] = asoc->last_reset_action[0]; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; + sctp_notify_stream_reset_tsn(stcb, asoc->sending_seq, (asoc->mapping_array_base_tsn + 1), 0); asoc->str_reset_seq_in++; } else if (asoc->str_reset_seq_in - 1 == seq) { sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[0], - stcb->asoc.last_sending_seq[0], - stcb->asoc.last_base_tsnsent[0] - ); + asoc->last_sending_seq[0], asoc->last_base_tsnsent[0]); } else if (asoc->str_reset_seq_in - 2 == seq) { sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[1], - stcb->asoc.last_sending_seq[1], - stcb->asoc.last_base_tsnsent[1] - ); + asoc->last_sending_seq[1], asoc->last_base_tsnsent[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } return (0); } @@ -3846,12 +3847,14 @@ sctp_handle_str_reset_request_out(struct /* move the reset action back one */ asoc->last_reset_action[1] = asoc->last_reset_action[0]; - if (trunc) { - asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + if (!(asoc->local_strreset_support & SCTP_ENABLE_RESET_STREAM_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if (trunc) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } else if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) { /* we can do it now */ sctp_reset_in_stream(stcb, number_entries, req->list_of_streams); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; } else { /* * we must queue it up and thus wait for the TSN's @@ -3865,8 +3868,8 @@ sctp_handle_str_reset_request_out(struct siz, SCTP_M_STRESET); if (liste == NULL) { /* gak out of memory */ - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_REJECT); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); return; } liste->tsn = tsn; @@ -3874,7 +3877,7 @@ sctp_handle_str_reset_request_out(struct memcpy(&liste->req, req, (sizeof(struct sctp_stream_reset_out_request) + (number_entries * sizeof(uint16_t)))); TAILQ_INSERT_TAIL(&asoc->resetHead, liste, next_resp); - asoc->last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; @@ -3891,7 +3894,7 @@ sctp_handle_str_reset_request_out(struct */ sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -3914,12 +3917,14 @@ sctp_handle_str_reset_add_strm(struct sc /* Now what would be the new total? */ if (asoc->str_reset_seq_in == seq) { num_stream += stcb->asoc.streamincnt; - if ((num_stream > stcb->asoc.max_inbound_streams) || + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + if (!(asoc->local_strreset_support & SCTP_ENABLE_CHANGE_ASSOC_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if ((num_stream > stcb->asoc.max_inbound_streams) || (num_stream > 0xffff)) { /* We must reject it they ask for to many */ denied: - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } else { /* Ok, we can do that :-) */ struct sctp_stream_in *oldstrm; @@ -3955,8 +3960,7 @@ sctp_handle_str_reset_add_strm(struct sc SCTP_FREE(oldstrm, SCTP_M_STRMI); /* update the size */ stcb->asoc.streamincnt = num_stream; - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); @@ -3974,7 +3978,7 @@ sctp_handle_str_reset_add_strm(struct sc */ sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -3996,10 +4000,12 @@ sctp_handle_str_reset_add_out_strm(struc num_stream = ntohs(str_add->number_of_streams); /* Now what would be the new total? */ if (asoc->str_reset_seq_in == seq) { - if (stcb->asoc.stream_reset_outstanding) { + stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; + if (!(asoc->local_strreset_support & SCTP_ENABLE_CHANGE_ASSOC_REQ)) { + asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; + } else if (stcb->asoc.stream_reset_outstanding) { /* We must reject it we have something pending */ - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS; } else { /* Ok, we can do that :-) */ int mychk; @@ -4007,14 +4013,12 @@ sctp_handle_str_reset_add_out_strm(struc mychk = stcb->asoc.streamoutcnt; mychk += num_stream; if (mychk < 0x10000) { - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_PERFORMED; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; if (sctp_send_str_reset_req(stcb, 0, NULL, 0, 0, 0, 1, num_stream, 0, 1)) { - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } } else { - stcb->asoc.last_reset_action[1] = stcb->asoc.last_reset_action[0]; - stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_REJECT; + stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_DENIED; } } sctp_add_stream_reset_result(chk, seq, stcb->asoc.last_reset_action[0]); @@ -4032,7 +4036,7 @@ sctp_handle_str_reset_add_out_strm(struc */ sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[1]); } else { - sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_BAD_SEQNO); + sctp_add_stream_reset_result(chk, seq, SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO); } } @@ -4046,7 +4050,6 @@ __attribute__((noinline)) int chk_length, param_len, ptype; struct sctp_paramhdr pstore; uint8_t cstore[SCTP_CHUNK_BUFFER_SIZE]; - uint32_t seq = 0; int num_req = 0; int trunc = 0; @@ -4124,7 +4127,7 @@ strres_nochunk: seq = ntohl(req_out->response_seq); if (seq == stcb->asoc.str_reset_seq_out) { /* implicit ack */ - (void)sctp_handle_stream_reset_response(stcb, seq, SCTP_STREAM_RESET_PERFORMED, NULL); + (void)sctp_handle_stream_reset_response(stcb, seq, SCTP_STREAM_RESET_RESULT_PERFORMED, NULL); } } sctp_handle_str_reset_request_out(stcb, chk, req_out, trunc); From owner-svn-src-head@FreeBSD.ORG Sat May 5 21:41:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF96D106566B; Sat, 5 May 2012 21:41:16 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9925C8FC18; Sat, 5 May 2012 21:41:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45LfGnv083264; Sat, 5 May 2012 21:41:16 GMT (envelope-from tuexen@svn.freebsd.org) Received: (from tuexen@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45LfGM6083258; Sat, 5 May 2012 21:41:16 GMT (envelope-from tuexen@svn.freebsd.org) Message-Id: <201205052141.q45LfGM6083258@svn.freebsd.org> From: Michael Tuexen Date: Sat, 5 May 2012 21:41:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235066 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 21:41:16 -0000 Author: tuexen Date: Sat May 5 21:41:16 2012 New Revision: 235066 URL: http://svn.freebsd.org/changeset/base/235066 Log: Provide the flags in the SCTP stream reconfig related notification as specified in RFC 6525. MFC after: 3 days Modified: head/sys/netinet/sctp_constants.h head/sys/netinet/sctp_input.c head/sys/netinet/sctp_uio.h head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctp_constants.h ============================================================================== --- head/sys/netinet/sctp_constants.h Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctp_constants.h Sat May 5 21:41:16 2012 (r235066) @@ -779,10 +779,9 @@ __FBSDID("$FreeBSD$"); #define SCTP_NOTIFY_SPECIAL_SP_FAIL 27 #define SCTP_NOTIFY_NO_PEER_AUTH 28 #define SCTP_NOTIFY_SENDER_DRY 29 -#define SCTP_NOTIFY_STR_RESET_ADD_OK 30 -#define SCTP_NOTIFY_STR_RESET_ADD_FAIL 31 -#define SCTP_NOTIFY_STR_RESET_INSTREAM_ADD_OK 32 -#define SCTP_NOTIFY_MAX 32 +#define SCTP_NOTIFY_STR_RESET_DENIED_OUT 30 +#define SCTP_NOTIFY_STR_RESET_DENIED_IN 31 +#define SCTP_NOTIFY_MAX 31 /* This is the value for messages that are NOT completely Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctp_input.c Sat May 5 21:41:16 2012 (r235066) @@ -3602,6 +3602,8 @@ sctp_handle_stream_reset_response(struct if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* do it */ sctp_reset_out_streams(stcb, number_entries, srparam->list_of_streams); + } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_OUT, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } else { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_OUT, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } @@ -3610,7 +3612,10 @@ sctp_handle_stream_reset_response(struct number_entries = (lparm_len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t); if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_IN, stcb, + number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + } else if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); } @@ -3630,16 +3635,22 @@ sctp_handle_stream_reset_response(struct /* Put the new streams into effect */ stcb->asoc.streamoutcnt += num_stream; sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); + } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGE_DENIED); } else { sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGED_DENIED); + SCTP_STREAM_CHANGE_FAILED); } } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; - if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { + if (action == SCTP_STREAM_RESET_RESULT_DENIED) { sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGED_DENIED); + SCTP_STREAM_CHANGE_DENIED); + } else if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { + sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, + SCTP_STREAM_CHANGE_FAILED); } } else if (type == SCTP_STR_RESET_TSN_REQUEST) { /** @@ -3682,9 +3693,12 @@ sctp_handle_stream_reset_response(struct sctp_reset_out_streams(stcb, 0, (uint16_t *) NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *) NULL); sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { + sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), + SCTP_ASSOC_RESET_DENIED); } else { sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), - SCTP_STREAM_RESET_FAILED); + SCTP_ASSOC_RESET_FAILED); } } /* get rid of the request and get the request flags */ Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctp_uio.h Sat May 5 21:41:16 2012 (r235066) @@ -454,7 +454,6 @@ struct sctp_stream_reset_event { #define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002 #define SCTP_STREAM_RESET_DENIED 0x0004 #define SCTP_STREAM_RESET_FAILED 0x0008 -#define SCTP_STREAM_CHANGED_DENIED 0x0010 /* * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Sat May 5 21:40:32 2012 (r235065) +++ head/sys/netinet/sctputil.c Sat May 5 21:41:16 2012 (r235066) @@ -3507,10 +3507,18 @@ sctp_ulp_notify(uint32_t notification, s sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED)); break; + case SCTP_NOTIFY_STR_RESET_DENIED_OUT: + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), + (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_DENIED)); + break; case SCTP_NOTIFY_STR_RESET_FAILED_IN: sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED)); break; + case SCTP_NOTIFY_STR_RESET_DENIED_IN: + sctp_notify_stream_reset(stcb, error, ((uint16_t *) data), + (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_DENIED)); + break; case SCTP_NOTIFY_ASCONF_ADD_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data, error); From owner-svn-src-head@FreeBSD.ORG Sat May 5 23:51:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B76510657A4; Sat, 5 May 2012 23:51:24 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 869DF8FC0A; Sat, 5 May 2012 23:51:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q45NpOeD087677; Sat, 5 May 2012 23:51:24 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q45NpOLB087675; Sat, 5 May 2012 23:51:24 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201205052351.q45NpOLB087675@svn.freebsd.org> From: David Xu Date: Sat, 5 May 2012 23:51:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235068 - head/lib/libthr/thread X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 23:51:25 -0000 Author: davidxu Date: Sat May 5 23:51:24 2012 New Revision: 235068 URL: http://svn.freebsd.org/changeset/base/235068 Log: Fix mis-merged line, move SC_LOOKUP() call to upper level. Modified: head/lib/libthr/thread/thr_sleepq.c Modified: head/lib/libthr/thread/thr_sleepq.c ============================================================================== --- head/lib/libthr/thread/thr_sleepq.c Sat May 5 22:44:08 2012 (r235067) +++ head/lib/libthr/thread/thr_sleepq.c Sat May 5 23:51:24 2012 (r235068) @@ -113,11 +113,11 @@ _sleepq_add(void *wchan, struct pthread struct sleepqueue_chain *sc; struct sleepqueue *sq; + sc = SC_LOOKUP(wchan); sq = _sleepq_lookup(wchan); if (sq != NULL) { SLIST_INSERT_HEAD(&sq->sq_freeq, td->sleepqueue, sq_flink); } else { - sc = SC_LOOKUP(wchan); sq = td->sleepqueue; LIST_INSERT_HEAD(&sc->sc_queues, sq, sq_hash); sq->sq_wchan = wchan;