diff options
author | obrien <obrien@FreeBSD.org> | 2013-02-08 16:10:16 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2013-02-08 16:10:16 +0000 |
commit | 3028e3f8aba938dfd0bf9fda987b8a72140b8027 (patch) | |
tree | b2f038222ff8a70f687652441df00d2b564c8abe /tools | |
parent | 952a6d5a7cd3d3f9007acfa06805262fc04a105f (diff) | |
parent | 1d08d5f677c1dfa810e381073590adbae19cc69f (diff) | |
download | FreeBSD-src-3028e3f8aba938dfd0bf9fda987b8a72140b8027.zip FreeBSD-src-3028e3f8aba938dfd0bf9fda987b8a72140b8027.tar.gz |
Sync with HEAD.
Diffstat (limited to 'tools')
79 files changed, 2898 insertions, 159 deletions
diff --git a/tools/build/Makefile b/tools/build/Makefile index 76493f7..b9b548e 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -21,6 +21,22 @@ config.h: ${.CURDIR}/../../lib/libmagic/config.h grep -v HAVE_GETLINE ${.ALLSRC} > ${.TARGET} .endif +_WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/pwd.h || true +.if ${_WITH_PWCACHEDB} == 0 +.PATH: ${.CURDIR}/../../contrib/libc-pwcache +CFLAGS+= -I${.CURDIR}/../../contrib/libc-pwcache \ + -I${.CURDIR}/../../lib/libc/include +SRCS+= pwcache.c +.endif + +_WITH_STRSVIS!= grep -c strsvis /usr/include/vis.h || true +.if ${_WITH_STRSVIS} == 0 +.PATH: ${.CURDIR}/../../contrib/libc-vis +SRCS+= vis.c +CFLAGS+= -I${.CURDIR}/../../contrib/libc-vis \ + -I${.CURDIR}/../../lib/libc/include +.endif + .if empty(SRCS) SRCS= dummy.c .endif diff --git a/tools/build/make_check/Makefile b/tools/build/make_check/Makefile index 3a0f6ad..9df224f 100644 --- a/tools/build/make_check/Makefile +++ b/tools/build/make_check/Makefile @@ -24,7 +24,7 @@ SMAKE= MAKEFLAGS= ${MAKE} -C ${.CURDIR} all: @echo '1..16' - @${SMAKE} C_check || { cd ${.CURDIR} ; ${MAKE} failure ; } + @${SMAKE} C_check || { ${MAKE} -C ${.CURDIR} failure ; } @echo "ok 1 - C_check # Test of -C flag existence detected no regression." @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \ diff -u ${.CURDIR}/regress.variables.out - || \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 7125018..b464c98 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -133,6 +133,7 @@ OLD_FILES+=usr/share/man/man3/atf-sh-api.3.gz OLD_FILES+=usr/share/man/man4/atf-test-case.4.gz OLD_FILES+=usr/share/man/man5/atf-formats.5.gz OLD_FILES+=usr/share/man/man7/atf.7.gz +OLD_FILES+=usr/share/mk/atf.test.mk OLD_DIRS+=usr/share/xml/atf OLD_FILES+=usr/share/xml/atf/tests-results.dtd OLD_DIRS+=usr/share/xsl/atf @@ -754,6 +755,8 @@ OLD_FILES+=usr/include/clang/3.1/wmmintrin.h OLD_FILES+=usr/include/clang/3.1/x86intrin.h OLD_FILES+=usr/include/clang/3.1/xmmintrin.h OLD_DIRS+=usr/include/clang/3.1 +OLD_FILES+=usr/include/clang/3.2/__wmmintrin_aes.h +OLD_FILES+=usr/include/clang/3.2/__wmmintrin_pclmul.h OLD_FILES+=usr/include/clang/3.2/altivec.h OLD_FILES+=usr/include/clang/3.2/ammintrin.h OLD_FILES+=usr/include/clang/3.2/avx2intrin.h @@ -762,6 +765,7 @@ OLD_FILES+=usr/include/clang/3.2/bmi2intrin.h OLD_FILES+=usr/include/clang/3.2/bmiintrin.h OLD_FILES+=usr/include/clang/3.2/cpuid.h OLD_FILES+=usr/include/clang/3.2/emmintrin.h +OLD_FILES+=usr/include/clang/3.2/f16cintrin.h OLD_FILES+=usr/include/clang/3.2/fma4intrin.h OLD_FILES+=usr/include/clang/3.2/fmaintrin.h OLD_FILES+=usr/include/clang/3.2/immintrin.h @@ -773,6 +777,7 @@ OLD_FILES+=usr/include/clang/3.2/module.map OLD_FILES+=usr/include/clang/3.2/nmmintrin.h OLD_FILES+=usr/include/clang/3.2/pmmintrin.h OLD_FILES+=usr/include/clang/3.2/popcntintrin.h +OLD_FILES+=usr/include/clang/3.2/rtmintrin.h OLD_FILES+=usr/include/clang/3.2/smmintrin.h OLD_FILES+=usr/include/clang/3.2/tmmintrin.h OLD_FILES+=usr/include/clang/3.2/unwind.h @@ -3649,6 +3654,95 @@ OLD_FILES+=usr/share/man/man8/ntptime.8.gz # to be filled in #.endif +.if ${MK_PC_SYSINSTALL} == no +# backend-partmanager +OLD_FILES+=usr/share/pc-sysinstall/backend-partmanager/create-part.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-partmanager/delete-part.sh +# backend-query +OLD_FILES+=usr/share/pc-sysinstall/backend-query/detect-emulation.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/detect-laptop.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/detect-nics.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/disk-info.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/disk-list.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/disk-part.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/enable-net.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/get-packages.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/list-components.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/list-config.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/list-mirrors.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/list-packages.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/list-rsync-backups.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/list-tzones.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/query-langs.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/send-logs.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/setup-ssh-keys.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/set-mirror.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/sys-mem.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/test-live.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/test-netup.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/update-part-list.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/xkeyboard-layouts.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/xkeyboard-models.sh +OLD_FILES+=usr/share/pc-sysinstall/backend-query/xkeyboard-variants.sh +# backend +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-bsdlabel.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-cleanup.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-disk.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-extractimage.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-ftp.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-installcomponents.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-installpackages.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-localize.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-mountdisk.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-mountoptical.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-networking.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-newfs.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-parse.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-packages.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-runcommands.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-unmount.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-upgrade.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions-users.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/functions.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/installimage.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/parseconfig.sh +OLD_FILES+=usr/share/pc-sysinstall/backend/startautoinstall.sh +# conf +OLD_FILES+=usr/share/pc-sysinstall/conf/avail-langs +OLD_FILES+=usr/share/pc-sysinstall/conf/exclude-from-upgrade +OLD_FILES+=usr/share/pc-sysinstall/conf/license/bsd-en.txt +OLD_FILES+=usr/share/pc-sysinstall/conf/license/intel-en.txt +OLD_FILES+=usr/share/pc-sysinstall/conf/license/nvidia-en.txt +OLD_FILES+=usr/share/pc-sysinstall/conf/pc-sysinstall.conf +# doc +OLD_FILES+=usr/share/pc-sysinstall/doc/help-disk-list +OLD_FILES+=usr/share/pc-sysinstall/doc/help-disk-size +OLD_FILES+=usr/share/pc-sysinstall/doc/help-index +OLD_FILES+=usr/share/pc-sysinstall/doc/help-start-autoinstall +# examples +OLD_FILES+=usr/share/examples/pc-sysinstall/README +OLD_FILES+=usr/share/examples/pc-sysinstall/pc-autoinstall.conf +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.fbsd-netinstall +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.geli +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.gmirror +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.netinstall +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.restore +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.rsync +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.upgrade +OLD_FILES+=usr/share/examples/pc-sysinstall/pcinstall.cfg.zfs +# pc-sysinstall +OLD_FILES+=usr/sbin/pc-sysinstall +OLD_FILES+=usr/share/man/man8/pc-sysinstall.8.gz +OLD_DIRS+=usr/share/pc-sysinstall/backend +OLD_DIRS+=usr/share/pc-sysinstall/backend-partmanager +OLD_DIRS+=usr/share/pc-sysinstall/backend-query +OLD_DIRS+=usr/share/pc-sysinstall/conf/license +OLD_DIRS+=usr/share/pc-sysinstall/conf +OLD_DIRS+=usr/share/pc-sysinstall/doc +OLD_DIRS+=usr/share/pc-sysinstall +OLD_DIRS+=usr/share/examples/pc-sysinstall +.endif + .if ${MK_PF} == no OLD_FILES+=etc/periodic/security/520.pfdenied OLD_FILES+=etc/pf.os @@ -3683,6 +3777,7 @@ OLD_FILES+=usr/sbin/pkg .endif .if ${MK_PKGTOOLS} == no +OLD_FILES+=etc/periodic/daily/220.backup-pkgdb OLD_FILES+=etc/periodic/daily/490.status-pkg-changes OLD_FILES+=etc/periodic/security/460.chkportsum OLD_FILES+=etc/periodic/weekly/400.status-pkg diff --git a/tools/build/options/WITHOUT_CLANG_FULL b/tools/build/options/WITHOUT_CLANG_FULL new file mode 100644 index 0000000..418b7d6 --- /dev/null +++ b/tools/build/options/WITHOUT_CLANG_FULL @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to avoid building the ARCMigrate, Rewriter and StaticAnalyzer components of +the Clang C/C++ compiler. diff --git a/tools/build/options/WITHOUT_CLANG_IS_CC b/tools/build/options/WITHOUT_CLANG_IS_CC new file mode 100644 index 0000000..0eef59c --- /dev/null +++ b/tools/build/options/WITHOUT_CLANG_IS_CC @@ -0,0 +1,6 @@ +.\" $FreeBSD$ +Set to install the GCC compiler as +.Pa /usr/bin/cc , +.Pa /usr/bin/c++ +and +.Pa /usr/bin/cpp . diff --git a/tools/build/options/WITHOUT_LIBCPLUSPLUS b/tools/build/options/WITHOUT_LIBCPLUSPLUS new file mode 100644 index 0000000..2449e30 --- /dev/null +++ b/tools/build/options/WITHOUT_LIBCPLUSPLUS @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to avoid building libcxxrt and libc++. diff --git a/tools/build/options/WITHOUT_LZMA_SUPPORT b/tools/build/options/WITHOUT_LZMA_SUPPORT new file mode 100644 index 0000000..627d464 --- /dev/null +++ b/tools/build/options/WITHOUT_LZMA_SUPPORT @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build some programs without optional lzma compression support. diff --git a/tools/build/options/WITHOUT_PC_SYSINSTALL b/tools/build/options/WITHOUT_PC_SYSINSTALL new file mode 100644 index 0000000..73b5ea3 --- /dev/null +++ b/tools/build/options/WITHOUT_PC_SYSINSTALL @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not build +.Xr pc-sysinstall 8 +and related programs. diff --git a/tools/build/options/WITH_ARM_EABI b/tools/build/options/WITH_ARM_EABI new file mode 100644 index 0000000..dba6e5f --- /dev/null +++ b/tools/build/options/WITH_ARM_EABI @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set the ARM ABI to EABI. diff --git a/tools/build/options/WITH_BSD_PATCH b/tools/build/options/WITH_BSD_PATCH new file mode 100644 index 0000000..8430d2a --- /dev/null +++ b/tools/build/options/WITH_BSD_PATCH @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Install BSD-licensed patch as 'patch' instead of GNU patch. diff --git a/tools/build/options/WITH_CLANG_FULL b/tools/build/options/WITH_CLANG_FULL new file mode 100644 index 0000000..59b4dec --- /dev/null +++ b/tools/build/options/WITH_CLANG_FULL @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to build the ARCMigrate, Rewriter and StaticAnalyzer components of the +Clang C/C++ compiler. diff --git a/tools/build/options/WITH_GPL_DTC b/tools/build/options/WITH_GPL_DTC new file mode 100644 index 0000000..e5a1e95 --- /dev/null +++ b/tools/build/options/WITH_GPL_DTC @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to build the GPL'd version of the device tree compiler from elinux.org, +instead of the BSD licensed one. diff --git a/tools/build/options/WITH_NMTREE b/tools/build/options/WITH_NMTREE new file mode 100644 index 0000000..cbaa873 --- /dev/null +++ b/tools/build/options/WITH_NMTREE @@ -0,0 +1,9 @@ +.\" $FreeBSD$ +Set to install +.Xr nmtree 8 +as +.Xr mtree 8 . +By default +.Xr fmtree 8 +is installed as +.Xr mtree 8 . diff --git a/tools/build/options/WITH_OPENSSH_NONE_CIPHER b/tools/build/options/WITH_OPENSSH_NONE_CIPHER new file mode 100644 index 0000000..8d44cc0 --- /dev/null +++ b/tools/build/options/WITH_OPENSSH_NONE_CIPHER @@ -0,0 +1,9 @@ +.\" $FreeBSD$ +Set to include the "None" cipher support in OpenSSH and its libraries. +Additional adjustments may need to be done to system configuration +files, such as +.Xr sshd_config 5 , +to enable this cipher. +Please see +.Pa /usr/src/crypto/openssh/README.hpn +for full details. diff --git a/tools/debugscripts/dot.gdbinit b/tools/debugscripts/dot.gdbinit index e57ac16..1a340c0 100644 --- a/tools/debugscripts/dot.gdbinit +++ b/tools/debugscripts/dot.gdbinit @@ -36,16 +36,16 @@ target remote $arg0 end document tr -Debug a remote system via serial or firewire interface. For example, specify 'tr /dev/cuad0' to use first serial port, or 'tr localhost:5556' for default firewire port. See also tr0, tr1 and trf commands. +Debug a remote system via serial or firewire interface. For example, specify 'tr /dev/cuau0' to use first serial port, or 'tr localhost:5556' for default firewire port. See also tr0, tr1 and trf commands. end # Convenience functions. These call tr. -# debug via cuad0 +# debug via cuau0 define tr0 -tr /dev/cuad0 +tr /dev/cuau0 end define tr1 -tr /dev/cuad1 +tr /dev/cuau1 end # Firewire define trf @@ -53,10 +53,10 @@ tr localhost:5556 end document tr0 -Debug a remote system via serial interface /dev/cuad0. See also tr, tr1 and trf commands. +Debug a remote system via serial interface /dev/cuau0. See also tr, tr1 and trf commands. end document tr1 -Debug a remote system via serial interface /dev/cuad1. See also tr, tr0 and trf commands. +Debug a remote system via serial interface /dev/cuau1. See also tr, tr0 and trf commands. end document trf Debug a remote system via firewire interface at default port 5556. See also tr, tr0 and tr1 commands. @@ -107,7 +107,7 @@ source gdbinit.kernel source gdbinit.machine echo Ready to go. Enter 'tr' to connect to the remote target\n -echo with /dev/cuad0, 'tr /dev/cuad1' to connect to a different port\n +echo with /dev/cuau0, 'tr /dev/cuau1' to connect to a different port\n echo or 'trf portno' to connect to the remote target with the firewire\n echo interface. portno defaults to 5556.\n echo \n diff --git a/tools/install.sh b/tools/install.sh index 489424f..c28bd89 100644 --- a/tools/install.sh +++ b/tools/install.sh @@ -30,12 +30,22 @@ # parse install's options and ignore them completely. dirmode="" +linkmode="" while [ $# -gt 0 ]; do case $1 in -d) dirmode="YES"; shift;; - -[bCcMpSsv]) shift;; - -[Bfgmo]) shift; shift;; - -[Bfgmo]*) shift;; + -[bCcpSsv]) shift;; + -[BDfghMmNoTU]) shift; shift;; + -[BDfghMmNoTU]*) shift;; + -l) + shift + case $1 in + *[sm]*) linkmode="symbolic";; # XXX: 'm' should prefer hard + *h*) linkmode="hard";; + *) echo "invalid link mode"; exit 1;; + esac + shift + ;; *) break; esac done @@ -51,7 +61,13 @@ if [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then fi # the remaining arguments are assumed to be files/dirs only. -if [ -z "$dirmode" ]; then +if [ -n "${linkmode}" ]; then + if [ "${linkmode}" = "symbolic" ]; then + ln -fsh "$@" + else + ln -f "$@" + fi +elif [ -z "$dirmode" ]; then exec install -p "$@" else exec install -d "$@" diff --git a/tools/regression/bin/sh/builtins/alias3.0 b/tools/regression/bin/sh/builtins/alias3.0 new file mode 100644 index 0000000..fe65e31f --- /dev/null +++ b/tools/regression/bin/sh/builtins/alias3.0 @@ -0,0 +1,12 @@ +# $FreeBSD$ +set -e + +unalias -a +alias foo=bar +alias bar= +alias quux="1 2 3" +alias foo=bar +alias bar= +alias quux="1 2 3" +alias +alias foo diff --git a/tools/regression/bin/sh/builtins/alias3.0.stdout b/tools/regression/bin/sh/builtins/alias3.0.stdout new file mode 100644 index 0000000..52efaf0 --- /dev/null +++ b/tools/regression/bin/sh/builtins/alias3.0.stdout @@ -0,0 +1,4 @@ +bar='' +foo=bar +quux='1 2 3' +foo=bar diff --git a/tools/regression/bin/sh/errors/write-error1.0 b/tools/regression/bin/sh/errors/write-error1.0 new file mode 100644 index 0000000..fcb52e7 --- /dev/null +++ b/tools/regression/bin/sh/errors/write-error1.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +! echo >&- 2>/dev/null diff --git a/tools/regression/bin/sh/execution/subshell1.0 b/tools/regression/bin/sh/execution/subshell1.0 new file mode 100644 index 0000000..347806e --- /dev/null +++ b/tools/regression/bin/sh/execution/subshell1.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +(eval "cd / +v=$(printf %0100000d 1) +echo \${#v}") +echo end diff --git a/tools/regression/bin/sh/execution/subshell1.0.stdout b/tools/regression/bin/sh/execution/subshell1.0.stdout new file mode 100644 index 0000000..8c71af3 --- /dev/null +++ b/tools/regression/bin/sh/execution/subshell1.0.stdout @@ -0,0 +1,2 @@ +100000 +end diff --git a/tools/regression/bin/sh/execution/subshell2.0 b/tools/regression/bin/sh/execution/subshell2.0 new file mode 100644 index 0000000..3216449 --- /dev/null +++ b/tools/regression/bin/sh/execution/subshell2.0 @@ -0,0 +1,10 @@ +# $FreeBSD$ + +f() { + x=2 +} +( + x=1 + f + [ "$x" = 2 ] +) diff --git a/tools/regression/bin/sh/execution/subshell3.0 b/tools/regression/bin/sh/execution/subshell3.0 new file mode 100644 index 0000000..9a87acb --- /dev/null +++ b/tools/regression/bin/sh/execution/subshell3.0 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +(false; exit) && exit 3 +exit 0 diff --git a/tools/regression/bin/sh/execution/subshell4.0 b/tools/regression/bin/sh/execution/subshell4.0 new file mode 100644 index 0000000..b39edb1 --- /dev/null +++ b/tools/regression/bin/sh/execution/subshell4.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +(eval "set v=1"; false) && echo bad; : diff --git a/tools/regression/bin/sh/expansion/cmdsubst14.0 b/tools/regression/bin/sh/expansion/cmdsubst14.0 new file mode 100644 index 0000000..bdbbb82 --- /dev/null +++ b/tools/regression/bin/sh/expansion/cmdsubst14.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +! v=`false + +` diff --git a/tools/regression/bin/sh/expansion/cmdsubst15.0 b/tools/regression/bin/sh/expansion/cmdsubst15.0 new file mode 100644 index 0000000..31d85d4 --- /dev/null +++ b/tools/regression/bin/sh/expansion/cmdsubst15.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +! v=`false; + +` diff --git a/tools/regression/bin/sh/expansion/cmdsubst16.0 b/tools/regression/bin/sh/expansion/cmdsubst16.0 new file mode 100644 index 0000000..71df562 --- /dev/null +++ b/tools/regression/bin/sh/expansion/cmdsubst16.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +f() { return 3; } +f +[ `echo $?` = 3 ] diff --git a/tools/regression/bin/sh/expansion/cmdsubst17.0 b/tools/regression/bin/sh/expansion/cmdsubst17.0 new file mode 100644 index 0000000..8c29e83 --- /dev/null +++ b/tools/regression/bin/sh/expansion/cmdsubst17.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +f() { return 3; } +f +[ `echo $?; :` = 3 ] diff --git a/tools/regression/bin/sh/parser/alias10.0 b/tools/regression/bin/sh/parser/alias10.0 new file mode 100644 index 0000000..30d99f4 --- /dev/null +++ b/tools/regression/bin/sh/parser/alias10.0 @@ -0,0 +1,9 @@ +# $FreeBSD$ + +# This test may start consuming memory indefinitely if it fails. +ulimit -t 5 2>/dev/null +ulimit -v 100000 2>/dev/null + +alias echo='echo' +alias echo='echo' +[ "`eval echo b`" = b ] diff --git a/tools/regression/bin/sh/parser/alias9.0 b/tools/regression/bin/sh/parser/alias9.0 new file mode 100644 index 0000000..6bd8808 --- /dev/null +++ b/tools/regression/bin/sh/parser/alias9.0 @@ -0,0 +1,6 @@ +# $FreeBSD$ + +alias alias0=: +alias alias0=exit +eval 'alias0 0' +exit 1 diff --git a/tools/regression/bin/sh/parser/empty-braces1.0 b/tools/regression/bin/sh/parser/empty-braces1.0 new file mode 100644 index 0000000..5ab443c --- /dev/null +++ b/tools/regression/bin/sh/parser/empty-braces1.0 @@ -0,0 +1,7 @@ +# $FreeBSD$ + +# Unfortunately, some scripts depend on the extension of allowing an empty +# pair of braces. + +{ } & +wait $! diff --git a/tools/regression/lib/libc/resolv/resolv.c b/tools/regression/lib/libc/resolv/resolv.c index c61d02e..d481ecf 100644 --- a/tools/regression/lib/libc/resolv/resolv.c +++ b/tools/regression/lib/libc/resolv/resolv.c @@ -226,7 +226,7 @@ resolvloop(void *p) { int *nhosts = (int *)p; if (*nhosts == 0) - return; + return NULL; do resolvone(*nhosts); while (--(*nhosts)); diff --git a/tools/regression/lib/libc/stdio/test-fmemopen.c b/tools/regression/lib/libc/stdio/test-fmemopen.c new file mode 100644 index 0000000..2788279 --- /dev/null +++ b/tools/regression/lib/libc/stdio/test-fmemopen.c @@ -0,0 +1,252 @@ +/*- +Copyright (C) 2013 Pietro Cerutti <gahr@FreeBSD.org> + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +*/ + +/* + * Test basic FILE * functions (fread, fwrite, fseek, fclose) against + * a FILE * retrieved using fmemopen() + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <assert.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> + +void +test_preexisting() +{ + /* + * Use a pre-existing buffer. + */ + + char buf[512]; + char buf2[512]; + char str[] = "Test writing some stuff"; + char str2[] = "AAAAAAAAA"; + char str3[] = "AAAA writing some stuff"; + FILE *fp; + size_t nofw, nofr; + int rc; + + /* Open a FILE * using fmemopen. */ + fp = fmemopen(buf, sizeof(buf), "w"); + assert(fp != NULL); + + /* Write to the buffer. */ + nofw = fwrite(str, 1, sizeof(str), fp); + assert(nofw == sizeof(str)); + + /* Close the FILE *. */ + rc = fclose(fp); + assert(rc == 0); + + /* Re-open the FILE * to read back the data. */ + fp = fmemopen(buf, sizeof(buf), "r"); + assert(fp != NULL); + + /* Read from the buffer. */ + bzero(buf2, sizeof(buf2)); + nofr = fread(buf2, 1, sizeof(buf2), fp); + assert(nofr == sizeof(buf2)); + + /* + * Since a write on a FILE * retrieved by fmemopen + * will add a '\0' (if there's space), we can check + * the strings for equality. + */ + assert(strcmp(str, buf2) == 0); + + /* Close the FILE *. */ + rc = fclose(fp); + assert(rc == 0); + + /* Now open a FILE * on the first 4 bytes of the string. */ + fp = fmemopen(str, 4, "w"); + assert(fp != NULL); + + /* + * Try to write more bytes than we shoud, we'll get a short count (4). + */ + nofw = fwrite(str2, 1, sizeof(str2), fp); + assert(nofw == 4); + + /* Close the FILE *. */ + rc = fclose(fp); + + /* Check that the string was not modified after the first 4 bytes. */ + assert(strcmp(str, str3) == 0); +} + +void +test_autoalloc() +{ + /* + * Let fmemopen allocate the buffer. + */ + + char str[] = "A quick test"; + FILE *fp; + long pos; + size_t nofw, nofr, i; + int rc; + + /* Open a FILE * using fmemopen. */ + fp = fmemopen(NULL, 512, "w+"); + assert(fp != NULL); + + /* fill the buffer */ + for (i = 0; i < 512; i++) { + nofw = fwrite("a", 1, 1, fp); + assert(nofw == 1); + } + + /* Get the current position into the stream. */ + pos = ftell(fp); + assert(pos == 512); + + /* + * Try to write past the end, we should get a short object count (0) + */ + nofw = fwrite("a", 1, 1, fp); + assert(nofw == 0); + + /* Close the FILE *. */ + rc = fclose(fp); + assert(rc == 0); +} + +void +test_data_length() +{ + /* + * Here we test that a read operation doesn't go past the end of the + * data actually written, and that a SEEK_END seeks from the end of the + * data, not of the whole buffer. + */ + FILE *fp; + char buf[512] = {'\0'}; + char str[] = "Test data length. "; + char str2[] = "Do we have two sentences?"; + char str3[sizeof(str) + sizeof(str2) -1]; + long pos; + size_t nofw, nofr; + int rc; + + /* Open a FILE * for updating our buffer. */ + fp = fmemopen(buf, sizeof(buf), "w+"); + assert(fp != NULL); + + /* Write our string into the buffer. */ + nofw = fwrite(str, 1, sizeof(str), fp); + assert(nofw == sizeof(str)); + + /* + * Now seek to the end and check that ftell + * gives us sizeof(str). + */ + rc = fseek(fp, 0, SEEK_END); + assert(rc == 0); + pos = ftell(fp); + assert(pos == sizeof(str)); + + /* Close the FILE *. */ + rc = fclose(fp); + assert(rc == 0); + + /* Reopen the buffer for appending. */ + fp = fmemopen(buf, sizeof(buf), "a+"); + assert(fp != NULL); + + /* We should now be writing after the first string. */ + nofw = fwrite(str2, 1, sizeof(str2), fp); + assert(nofw == sizeof(str2)); + + /* Rewind the FILE *. */ + rc = fseek(fp, 0, SEEK_SET); + assert(rc == 0); + + /* Make sure we're at the beginning. */ + pos = ftell(fp); + assert(pos == 0); + + /* Read the whole buffer. */ + nofr = fread(str3, 1, sizeof(buf), fp); + assert(nofr == sizeof(str3)); + + /* Make sure the two strings are there. */ + assert(strncmp(str3, str, sizeof(str) - 1) == 0); + assert(strncmp(str3 + sizeof(str) - 1, str2, sizeof(str2)) == 0); + + /* Close the FILE *. */ + rc = fclose(fp); + assert(rc == 0); +} + +void +test_binary() +{ + /* + * Make sure that NULL bytes are never appended when opening a buffer + * in binary mode. + */ + + FILE *fp; + char buf[20]; + char str[] = "Test"; + size_t nofw; + int rc, i; + + /* Pre-fill the buffer. */ + memset(buf, 'A', sizeof(buf)); + + /* Open a FILE * in binary mode. */ + fp = fmemopen(buf, sizeof(buf), "w+b"); + assert(fp != NULL); + + /* Write some data into it. */ + nofw = fwrite(str, 1, strlen(str), fp); + assert(nofw == strlen(str)); + + /* Make sure that the buffer doesn't contain any NULL bytes. */ + for (i = 0; i < sizeof(buf); i++) + assert(buf[i] != '\0'); + + /* Close the FILE *. */ + rc = fclose(fp); + assert(rc == 0); +} + +int +main(void) +{ + test_autoalloc(); + test_preexisting(); + test_data_length(); + test_binary(); + return (0); +} diff --git a/tools/regression/lib/libc/stdio/test-fmemopen.t b/tools/regression/lib/libc/stdio/test-fmemopen.t new file mode 100644 index 0000000..8bdfd03 --- /dev/null +++ b/tools/regression/lib/libc/stdio/test-fmemopen.t @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD$ + +cd `dirname $0` + +executable=`basename $0 .t` + +make $executable 2>&1 > /dev/null + +exec ./$executable diff --git a/tools/regression/lib/libc/stdio/test-perror.c b/tools/regression/lib/libc/stdio/test-perror.c index 992b734..24aca89 100644 --- a/tools/regression/lib/libc/stdio/test-perror.c +++ b/tools/regression/lib/libc/stdio/test-perror.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> static void cleanup(void); static char tmpfil[PATH_MAX]; diff --git a/tools/regression/netinet/arphold/arphold.c b/tools/regression/netinet/arphold/arphold.c index 092461d..8d694fe 100644 --- a/tools/regression/netinet/arphold/arphold.c +++ b/tools/regression/netinet/arphold/arphold.c @@ -63,7 +63,6 @@ main(int argc, char **argv) int sock; int maxhold; - int wait; size_t size = sizeof(maxhold); struct sockaddr_in dest; char message[MSG_SIZE]; diff --git a/tools/regression/netinet/udpzerobyte/udpzerobyte.c b/tools/regression/netinet/udpzerobyte/udpzerobyte.c index c396fc8..c191492 100644 --- a/tools/regression/netinet/udpzerobyte/udpzerobyte.c +++ b/tools/regression/netinet/udpzerobyte/udpzerobyte.c @@ -80,7 +80,7 @@ test(int domain, const char *domainstr, struct sockaddr *sa, socklen_t salen) size = recv(sock_receive, NULL, 0, 0); if (size > 0) - errx(-1, "Protocol %s recv(sock_receive, NULL, 0) before: %d", + errx(-1, "Protocol %s recv(sock_receive, NULL, 0) before: %zd", domainstr, size); else if (size < 0) err(-1, "Protocol %s recv(sock_receive, NULL, 0) before", @@ -98,7 +98,7 @@ test(int domain, const char *domainstr, struct sockaddr *sa, socklen_t salen) size = recv(sock_receive, NULL, 0, 0); if (size > 0) - errx(-1, "Protocol %s recv(sock_receive, NULL, 0) after: %d", + errx(-1, "Protocol %s recv(sock_receive, NULL, 0) after: %zd", domainstr, size); else if (size < 0) err(-1, "Protocol %s recv(sock_receive, NULL, 0) after", diff --git a/tools/regression/netipx/ipxdgramloopback/ipxdgramloopback.c b/tools/regression/netipx/ipxdgramloopback/ipxdgramloopback.c index b969b48..73b6a2a 100644 --- a/tools/regression/netipx/ipxdgramloopback/ipxdgramloopback.c +++ b/tools/regression/netipx/ipxdgramloopback/ipxdgramloopback.c @@ -95,7 +95,7 @@ main(int argc, char *argv[]) if (len < 0) err(-1, "sendto()"); if (len != sizeof(packet)) - errx(-1, "sendto(): short send (%d length, %d sent)", + errx(-1, "sendto(): short send (%zu length, %zd sent)", sizeof(packet), len); sleep(1); /* Arbitrary non-zero amount. */ @@ -105,7 +105,7 @@ main(int argc, char *argv[]) if (len < 0) err(-1, "recv()"); if (len != sizeof(packet)) - errx(-1, "recv(): short receive (%d length, %d received)", + errx(-1, "recv(): short receive (%zu length, %zd received)", sizeof(packet), len); for (i = 0; i < PACKETLEN; i++) { diff --git a/tools/regression/sockets/sblock/sblock.c b/tools/regression/sockets/sblock/sblock.c index a508811..a9f9518 100644 --- a/tools/regression/sockets/sblock/sblock.c +++ b/tools/regression/sockets/sblock/sblock.c @@ -76,7 +76,7 @@ blocking_recver(int fd) if (len == 0) errx(-1, "FAIL: blocking_recver: recv: eof"); if (len != 1) - errx(-1, "FAIL: blocking_recver: recv: %d bytes", len); + errx(-1, "FAIL: blocking_recver: recv: %zd bytes", len); if (interrupted) errx(-1, "FAIL: blocking_recver: interrupted wrong pid"); } @@ -134,7 +134,7 @@ signaller(pid_t locking_recver_pid, int fd) return; } if (len != sizeof(ch)) { - warnx("signaller send ret %d", len); + warnx("signaller send ret %zd", len); return; } if (close(fd) < 0) { diff --git a/tools/regression/sockets/sigpipe/sigpipe.c b/tools/regression/sockets/sigpipe/sigpipe.c index 0422576..641536a 100644 --- a/tools/regression/sockets/sigpipe/sigpipe.c +++ b/tools/regression/sockets/sigpipe/sigpipe.c @@ -97,7 +97,7 @@ test_send(const char *testname, int sock) return; err(-1, "%s: send", testname); } - errx(-1, "%s: send: returned %d", testname, len); + errx(-1, "%s: send: returned %zd", testname, len); } static void @@ -113,7 +113,7 @@ test_write(const char *testname, int sock) return; err(-1, "%s: write", testname); } - errx(-1, "%s: write: returned %d", testname, len); + errx(-1, "%s: write: returned %zd", testname, len); } static void diff --git a/tools/regression/sockets/unix_cmsg/unix_cmsg.c b/tools/regression/sockets/unix_cmsg/unix_cmsg.c index c16b468..06728d7 100644 --- a/tools/regression/sockets/unix_cmsg/unix_cmsg.c +++ b/tools/regression/sockets/unix_cmsg/unix_cmsg.c @@ -449,7 +449,7 @@ create_socket(char *sock_path, size_t sock_path_len, struct sockaddr_un *addr) goto failed; } - memset(addr, 0, sizeof(addr)); + memset(addr, 0, sizeof(*addr)); addr->sun_family = AF_LOCAL; if (strlen(sock_path) >= sizeof(addr->sun_path)) { logmsgx("create_socket: too long path name (>= %lu) for local domain socket", diff --git a/tools/regression/sockets/unix_seqpacket_exercise/unix_seqpacket_exercise.c b/tools/regression/sockets/unix_seqpacket_exercise/unix_seqpacket_exercise.c index 00eebb4..a16c384 100644 --- a/tools/regression/sockets/unix_seqpacket_exercise/unix_seqpacket_exercise.c +++ b/tools/regression/sockets/unix_seqpacket_exercise/unix_seqpacket_exercise.c @@ -50,21 +50,21 @@ __FBSDID("$FreeBSD$"); #define SEQPACKET_SNDBUF (131072-16) #define FAILERR(str) err(-1, "%s: %s", __func__, str) -#define FAILNERR(str, n) err(-1, "%s %d: %s", __func__, n, str) -#define FAILNMERR(str, n, m) err(-1, "%s %d %d: %s", __func__, n, m, str) +#define FAILNERR(str, n) err(-1, "%s %zd: %s", __func__, n, str) +#define FAILNMERR(str, n, m) err(-1, "%s %zd %d: %s", __func__, n, m, str) #define FAILERRX(str) errx(-1, "%s: %s", __func__, str) -#define FAILNERRX(str, n) errx(-1, "%s %d: %s", __func__, n, str) -#define FAILNMERRX(str, n, m) errx(-1, "%s %d %d: %s", __func__, n, m, str) +#define FAILNERRX(str, n) errx(-1, "%s %zd: %s", __func__, n, str) +#define FAILNMERRX(str, n, m) errx(-1, "%s %zd %d: %s", __func__, n, m, str) static int ann = 0; #define ANN() (ann ? warnx("%s: start", __func__) : 0) -#define ANNN(n) (ann ? warnx("%s %d: start", __func__, (n)) : 0) -#define ANNNM(n, m) (ann ? warnx("%s %d %d: start", __func__, (n), (m)) : 0) +#define ANNN(n) (ann ? warnx("%s %zd: start", __func__, (n)) : 0) +#define ANNNM(n, m) (ann ? warnx("%s %zd %d: start", __func__, (n), (m)):0) #define OK() warnx("%s: ok", __func__) -#define OKN(n) warnx("%s %d: ok", __func__, (n)) -#define OKNM(n, m) warnx("%s %d %d: ok", __func__, (n), (m)) +#define OKN(n) warnx("%s %zd: ok", __func__, (n)) +#define OKNM(n, m) warnx("%s %zd %d: ok", __func__, (n), (m)) #ifdef SO_NOSIGPIPE #define NEW_SOCKET(s) do { \ @@ -168,7 +168,7 @@ server(int s_listen) break; } if (ssize_send != ssize_recv) - warnx("server: recv %d sent %d", + warnx("server: recv %zd sent %zd", ssize_recv, ssize_send); } while (1); close(s_accept); diff --git a/tools/regression/sockets/zerosend/zerosend.c b/tools/regression/sockets/zerosend/zerosend.c index b51155d..a42ec51 100644 --- a/tools/regression/sockets/zerosend/zerosend.c +++ b/tools/regression/sockets/zerosend/zerosend.c @@ -56,7 +56,7 @@ try_0send(const char *test, int fd) if (len < 0) err(-1, "%s: try_0send", test); if (len != 0) - errx(-1, "%s: try_0send: returned %d", test, len); + errx(-1, "%s: try_0send: returned %zd", test, len); } static void @@ -70,7 +70,7 @@ try_0write(const char *test, int fd) if (len < 0) err(-1, "%s: try_0write", test); if (len != 0) - errx(-1, "%s: try_0write: returned %d", test, len); + errx(-1, "%s: try_0write: returned %zd", test, len); } static void diff --git a/tools/regression/ufs/uprintf/ufs_uprintf.c b/tools/regression/ufs/uprintf/ufs_uprintf.c index d9f7125..17aa71e 100644 --- a/tools/regression/ufs/uprintf/ufs_uprintf.c +++ b/tools/regression/ufs/uprintf/ufs_uprintf.c @@ -86,7 +86,7 @@ fill_blocks(void) if (len < 0) break; if (len != BLOCKSIZE) { - warnx("fill_blocks: write(%d) returned %d", + warnx("fill_blocks: write(%d) returned %zd", BLOCKSIZE, len); close(fd); (void)unlink(BLOCKS_FILENAME); diff --git a/tools/regression/usr.bin/printf/regress.sh b/tools/regression/usr.bin/printf/regress.sh index 4ce282f..3f7f9aa 100644 --- a/tools/regression/usr.bin/printf/regress.sh +++ b/tools/regression/usr.bin/printf/regress.sh @@ -2,7 +2,7 @@ REGRESSION_START($1) -echo '1..11' +echo '1..12' REGRESSION_TEST(`b', `printf "abc%b%b" "def\n" "\cghi"') REGRESSION_TEST(`d', `printf "%d,%5d,%.5d,%0*d,%.*d\n" 123 123 123 5 123 5 123') @@ -15,5 +15,9 @@ REGRESSION_TEST(`m3', `printf "%%%s\n" abc def ghi jkl') REGRESSION_TEST(`m4', `printf "%d,%f,%c,%s\n"') REGRESSION_TEST(`m5', `printf -- "-d\n"') REGRESSION_TEST(`s', `printf "%.3s,%-5s\n" abcd abc') +REGRESSION_TEST('zero', `printf "%u%u\n" 15') +REGRESSION_TEST('zero', `printf "%d%d\n" 15') +REGRESSION_TEST('zero', `printf "%d%u\n" 15') +REGRESSION_TEST('zero', `printf "%u%d\n" 15') REGRESSION_END() diff --git a/tools/regression/usr.bin/printf/regress.zero.out b/tools/regression/usr.bin/printf/regress.zero.out new file mode 100644 index 0000000..fa8f08c --- /dev/null +++ b/tools/regression/usr.bin/printf/regress.zero.out @@ -0,0 +1 @@ +150 diff --git a/tools/test/ppsapi/Makefile b/tools/test/ppsapi/Makefile index f0110ed..5c4a065 100644 --- a/tools/test/ppsapi/Makefile +++ b/tools/test/ppsapi/Makefile @@ -8,4 +8,4 @@ WARNS?= 5 .include <bsd.prog.mk> test: ${PROG} - ./${PROG} /dev/cuad0 + ./${PROG} /dev/cuau0 diff --git a/tools/test/ppsapi/README b/tools/test/ppsapi/README index ad8dacf..ea0c3e8 100644 --- a/tools/test/ppsapi/README +++ b/tools/test/ppsapi/README @@ -16,7 +16,7 @@ Options: The output looks like: -# ./ppsapitest -C /dev/cuad4 +# ./ppsapitest -C /dev/cuau4 1070915603 .703680117 119 1070915940 .902275676 121 1070915941 .703657317 120 1070915941 .902327516 122 1070915942 .703657077 121 1070915942 .902367957 123 @@ -36,7 +36,7 @@ Columns: (If the -C option had not been specified, twice as many lines would be output: -# ./ppsapitest /dev/cuad4 +# ./ppsapitest /dev/cuau4 1070916432 .703624557 125 1070915945 .902527078 126 1070916432 .703624557 125 1070916432 .902303156 127 1070916433 .703624557 126 1070916432 .902303156 127 diff --git a/tools/test/pthread_vfork/pthread_vfork_test.c b/tools/test/pthread_vfork/pthread_vfork_test.c index e004727..925c862 100644 --- a/tools/test/pthread_vfork/pthread_vfork_test.c +++ b/tools/test/pthread_vfork/pthread_vfork_test.c @@ -29,6 +29,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <sys/types.h> +#include <sys/wait.h> #include <err.h> #include <pthread.h> #include <signal.h> @@ -39,10 +41,11 @@ __FBSDID("$FreeBSD$"); #define NUM_THREADS 100 -void * -vfork_test(void *threadid) +static void * +vfork_test(void *threadid __unused) { - pid_t pid; + pid_t pid, wpid; + int status; for (;;) { pid = vfork(); @@ -50,10 +53,20 @@ vfork_test(void *threadid) _exit(0); else if (pid == -1) err(1, "Failed to vfork"); + else { + wpid = waitpid(pid, &status, 0); + if (wpid == -1) + err(1, "waitpid"); + } } return (NULL); } +static void +sighandler(int signo __unused) +{ +} + /* * This program invokes multiple threads and each thread calls * vfork() system call. @@ -63,19 +76,24 @@ main(void) { pthread_t threads[NUM_THREADS]; struct sigaction reapchildren; + sigset_t sigchld_mask; int rc, t; memset(&reapchildren, 0, sizeof(reapchildren)); - reapchildren.sa_handler = SIG_IGN; - - /* Automatically reap zombies. */ + reapchildren.sa_handler = sighandler; if (sigaction(SIGCHLD, &reapchildren, NULL) == -1) err(1, "Could not sigaction(SIGCHLD)"); + sigemptyset(&sigchld_mask); + sigaddset(&sigchld_mask, SIGCHLD); + if (sigprocmask(SIG_BLOCK, &sigchld_mask, NULL) == -1) + err(1, "sigprocmask"); + for (t = 0; t < NUM_THREADS; t++) { - rc = pthread_create(&threads[t], NULL, vfork_test, (void *)t); + rc = pthread_create(&threads[t], NULL, vfork_test, &t); if (rc) errc(1, rc, "pthread_create"); } + pause(); return (0); } diff --git a/tools/tools/ath/Makefile b/tools/tools/ath/Makefile index 0faadbf..c4c81ba 100644 --- a/tools/tools/ath/Makefile +++ b/tools/tools/ath/Makefile @@ -3,6 +3,6 @@ SUBDIR= arcode athdebug athdecode athkey athpoke athprom athrd athregs SUBDIR+= athstats ath_prom_read athradar athaggrstats SUBDIR+= ath_ee_v14_print ath_ee_v4k_print ath_ee_9287_print -SUBDIR+= athsurvey athratestats +SUBDIR+= athsurvey athratestats athspectral .include <bsd.subdir.mk> diff --git a/tools/tools/ath/arcode/arcode.c b/tools/tools/ath/arcode/arcode.c index 31e02cd..463b954 100644 --- a/tools/tools/ath/arcode/arcode.c +++ b/tools/tools/ath/arcode/arcode.c @@ -106,7 +106,7 @@ main(int argc, const char *argv[]) op_mark(&a); break; default: - printf("op: %s; reg: %x; val: %x\n", + printf("op: %d; reg: 0x%x; val: 0x%x\n", a.op, a.reg, a.val); } } diff --git a/tools/tools/ath/ath_prom_read/ath_prom_read.c b/tools/tools/ath/ath_prom_read/ath_prom_read.c index f123aaa..3111021 100644 --- a/tools/tools/ath/ath_prom_read/ath_prom_read.c +++ b/tools/tools/ath/ath_prom_read/ath_prom_read.c @@ -123,7 +123,7 @@ main(int argc, char *argv[]) atd.ad_out_data = (caddr_t) eep; atd.ad_out_size = sizeof(eep); if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); /* Dump file? Then just write to it */ if (dumpname != NULL) { diff --git a/tools/tools/ath/athalq/Makefile b/tools/tools/ath/athalq/Makefile new file mode 100644 index 0000000..9ad4b140 --- /dev/null +++ b/tools/tools/ath/athalq/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +PROG= athalq +NOMAN= yes + +SRCS= main.c ar5210_ds.c ar5211_ds.c ar5212_ds.c ar5416_ds.c +# SRCS+= ar9300_ds.c + +.include <../Makefile.inc> + +.include <bsd.prog.mk> diff --git a/tools/tools/ath/athalq/ar5210_ds.c b/tools/tools/ath/athalq/ar5210_ds.c new file mode 100644 index 0000000..79b04d9 --- /dev/null +++ b/tools/tools/ath/athalq/ar5210_ds.c @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> +#include <dev/ath/ath_hal/ar5210/ar5210desc.h> + +#include "ar5210_ds.h" + +#define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S ) +#define MF(_v, _f) ( !! ((_v) & (_f))) + +static void +ar5210_decode_txstatus(struct if_ath_alq_payload *a) +{ + struct ar5210_desc txs; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txs, &a->payload, sizeof(struct ar5210_desc)); + + printf("[%u] [%llu] TXSTATUS\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + /* ds_txstatus0 */ + printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n", + MF(txs.ds_status0, AR_FrmXmitOK), + MF(txs.ds_status0, AR_ExcessiveRetries), + MF(txs.ds_status0, AR_FIFOUnderrun), + MF(txs.ds_status0, AR_Filtered)); + printf(" LongRetryCnt=%d, ShortRetryCnt=%d\n", + MS(txs.ds_status0, AR_LongRetryCnt), + MS(txs.ds_status0, AR_ShortRetryCnt)); + printf(" SndTimestamp=0x%04x\n", + MS(txs.ds_status0, AR_SendTimestamp)); + + /* ds_txstatus1 */ + printf(" Done=%d, SeqNum=0x%04x, AckRSSI=%d\n", + MF(txs.ds_status1, AR_Done), + txs.ds_status1 & AR_SeqNum, + MS(txs.ds_status1, AR_AckSigStrength)); + + printf("\n ------\n"); +} + +static void +ar5210_decode_txdesc(struct if_ath_alq_payload *a) +{ + struct ar5210_desc txc; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txc, &a->payload, sizeof(struct ar5210_desc)); + + printf("[%u] [%llu] TXD\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + txc.ds_link, + txc.ds_data); + + /* ds_ctl0 */ + printf(" Frame Len=%d\n", txc.ds_ctl0 & AR_FrameLen); + printf(" TX Rate=0x%02x, RtsEna=%d, ClrDstMask=%d AntModeXmit=0x%02x\n", + MS(txc.ds_ctl0, AR_XmitRate), + MF(txc.ds_ctl0, AR_RTSCTSEnable), + MF(txc.ds_ctl0, AR_ClearDestMask), + MF(txc.ds_ctl0, AR_AntModeXmit)); + printf(" FrmType=0x%02x, TxIntrReq=%d\n", + MS(txc.ds_ctl0, AR_FrmType), + MF(txc.ds_ctl0, AR_TxInterReq)); + printf(" LongPkt=%d\n", MF(txc.ds_ctl0, AR_LongPkt)); + + /* ds_ctl1 */ + printf(" BufLen=%d, TxMore=%d, EncryptKeyIdx=%d, RtsDuration=%d\n", + txc.ds_ctl1 & AR_BufLen, + MF(txc.ds_ctl1, AR_More), + MS(txc.ds_ctl1, AR_EncryptKeyIdx), + MS(txc.ds_ctl1, AR_RTSDuration)); + + printf("\n ------ \n"); +} + +static void +ar5210_decode_rxstatus(struct if_ath_alq_payload *a) +{ + struct ar5210_desc rxs; + + /* XXX assumes rxs is smaller than PAYLOAD_LEN! */ + memcpy(&rxs, &a->payload, sizeof(struct ar5210_desc)); + + printf("[%u] [%llu] RXSTATUS\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + rxs.ds_link, + rxs.ds_data); + + /* ds_rxstatus0 */ + printf(" DataLen=%d, ArMore=%d, RSSI=%d, RcvAntenna=0x%x\n", + rxs.ds_status0 & AR_DataLen, + MF(rxs.ds_status0, AR_More), + MS(rxs.ds_status0, AR_RcvSigStrength), + MF(rxs.ds_status0, AR_RcvAntenna)); + + /* ds_rxstatus1 */ + printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n", + MF(rxs.ds_status1, AR_Done), + MF(rxs.ds_status1, AR_FrmRcvOK), + MF(rxs.ds_status1, AR_CRCErr), + MF(rxs.ds_status1, AR_DecryptCRCErr)); + printf(" KeyIdxValid=%d\n", + MF(rxs.ds_status1, AR_KeyIdxValid)); + + printf(" PhyErrCode=0x%02x\n", + MS(rxs.ds_status1, AR_PHYErr)); + + printf(" KeyMiss=%d\n", + MF(rxs.ds_status1, AR_KeyCacheMiss)); + + printf(" Timetamp: 0x%05x\n", + MS(rxs.ds_status1, AR_RcvTimestamp)); + + printf("\n ------\n"); +} + +void +ar5210_alq_payload(struct if_ath_alq_payload *a) +{ + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */ + ar5210_decode_txstatus(a); + break; + case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */ + ar5210_decode_rxstatus(a); + break; + case ATH_ALQ_EDMA_TXDESC: /* TXDESC */ + ar5210_decode_txdesc(a); + break; + default: + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), be16toh(a->hdr.len)); + } +} diff --git a/tools/tools/ath/athalq/ar5210_ds.h b/tools/tools/ath/athalq/ar5210_ds.h new file mode 100644 index 0000000..754a137 --- /dev/null +++ b/tools/tools/ath/athalq/ar5210_ds.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ +#ifndef __AR5210_DS_H__ +#define __AR5210_DS_H__ + +extern void ar5210_alq_payload(struct if_ath_alq_payload *a); + +#endif /* __AR5210_DS_H__ */ diff --git a/tools/tools/ath/athalq/ar5211_ds.c b/tools/tools/ath/athalq/ar5211_ds.c new file mode 100644 index 0000000..0f0984f --- /dev/null +++ b/tools/tools/ath/athalq/ar5211_ds.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> +#include <dev/ath/ath_hal/ar5211/ar5211desc.h> + +#include "ar5211_ds.h" + +#define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S ) +#define MF(_v, _f) ( !! ((_v) & (_f))) + +static void +ar5211_decode_txstatus(struct if_ath_alq_payload *a) +{ + struct ar5211_desc txs; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txs, &a->payload, sizeof(struct ar5211_desc)); + + printf("[%u] [%llu] TXSTATUS\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + /* ds_txstatus0 */ + printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n", + MF(txs.ds_status0, AR_FrmXmitOK), + MF(txs.ds_status0, AR_ExcessiveRetries), + MF(txs.ds_status0, AR_FIFOUnderrun), + MF(txs.ds_status0, AR_Filtered)); + printf(" LongRetryCnt=%d, ShortRetryCnt=%d, VCollCnt=%d\n", + MS(txs.ds_status0, AR_LongRetryCnt), + MS(txs.ds_status0, AR_ShortRetryCnt), + MS(txs.ds_status0, AR_VirtCollCnt)); + printf(" SndTimestamp=0x%04x\n", + MS(txs.ds_status0, AR_SendTimestamp)); + + /* ds_txstatus1 */ + printf(" Done=%d, SeqNum=0x%04x, AckRSSI=%d\n", + MF(txs.ds_status1, AR_Done), + MS(txs.ds_status1, AR_SeqNum), + MS(txs.ds_status1, AR_AckSigStrength)); + + printf("\n ------\n"); +} + +static void +ar5211_decode_txdesc(struct if_ath_alq_payload *a) +{ + struct ar5211_desc txc; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txc, &a->payload, sizeof(struct ar5211_desc)); + + printf("[%u] [%llu] TXD\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + txc.ds_link, + txc.ds_data); + + /* ds_ctl0 */ + printf(" Frame Len=%d\n", txc.ds_ctl0 & AR_FrameLen); + printf(" TX Rate=0x%02x, RtsEna=%d, Veol=%d, ClrDstMask=%d AntModeXmit=0x%02x\n", + MS(txc.ds_ctl0, AR_XmitRate), + MF(txc.ds_ctl0, AR_RTSCTSEnable), + MF(txc.ds_ctl0, AR_VEOL), + MF(txc.ds_ctl0, AR_ClearDestMask), + MF(txc.ds_ctl0, AR_AntModeXmit)); + printf(" TxIntrReq=%d\n", + MF(txc.ds_ctl0, AR_TxInterReq)); + + /* ds_ctl1 */ + printf(" BufLen=%d, TxMore=%d, EncryptKeyIdx=%d,FrType=0x%x\n", + txc.ds_ctl1 & AR_BufLen, + MF(txc.ds_ctl1, AR_More), + MS(txc.ds_ctl1, AR_EncryptKeyIdx), + MS(txc.ds_ctl1, AR_FrmType)); + printf(" NoAck=%d\n", MF(txc.ds_ctl1, AR_NoAck)); + + printf("\n ------ \n"); +} + +static void +ar5211_decode_rxstatus(struct if_ath_alq_payload *a) +{ + struct ar5211_desc rxs; + + /* XXX assumes rxs is smaller than PAYLOAD_LEN! */ + memcpy(&rxs, &a->payload, sizeof(struct ar5211_desc)); + + printf("[%u] [%llu] RXSTATUS\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + rxs.ds_link, + rxs.ds_data); + + /* ds_rxstatus0 */ + printf(" DataLen=%d, ArMore=%d, RSSI=%d, RcvAntenna=0x%x\n", + rxs.ds_status0 & AR_DataLen, + MF(rxs.ds_status0, AR_More), + MS(rxs.ds_status0, AR_RcvSigStrength), + MS(rxs.ds_status0, AR_RcvAntenna)); + + /* ds_rxstatus1 */ + printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n", + MF(rxs.ds_status1, AR_Done), + MF(rxs.ds_status1, AR_FrmRcvOK), + MF(rxs.ds_status1, AR_CRCErr), + MF(rxs.ds_status1, AR_DecryptCRCErr)); + printf(" KeyIdxValid=%d\n", + MF(rxs.ds_status1, AR_KeyIdxValid)); + + printf(" PhyErrCode=0x%02x\n", + MS(rxs.ds_status1, AR_PHYErr)); + + printf(" KeyMiss=%d\n", + MF(rxs.ds_status1, AR_KeyCacheMiss)); + + printf(" Timetamp: 0x%05x\n", + MS(rxs.ds_status1, AR_RcvTimestamp)); + + printf("\n ------\n"); +} + +void +ar5211_alq_payload(struct if_ath_alq_payload *a) +{ + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */ + ar5211_decode_txstatus(a); + break; + case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */ + ar5211_decode_rxstatus(a); + break; + case ATH_ALQ_EDMA_TXDESC: /* TXDESC */ + ar5211_decode_txdesc(a); + break; + default: + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), be16toh(a->hdr.len)); + } +} diff --git a/tools/tools/ath/athalq/ar5211_ds.h b/tools/tools/ath/athalq/ar5211_ds.h new file mode 100644 index 0000000..96d22ac --- /dev/null +++ b/tools/tools/ath/athalq/ar5211_ds.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ +#ifndef __AR5211_DS_H__ +#define __AR5211_DS_H__ + +extern void ar5211_alq_payload(struct if_ath_alq_payload *a); + +#endif /* __AR5211_DS_H__ */ diff --git a/tools/tools/ath/athalq/ar5212_ds.c b/tools/tools/ath/athalq/ar5212_ds.c new file mode 100644 index 0000000..a6364a4 --- /dev/null +++ b/tools/tools/ath/athalq/ar5212_ds.c @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> +#include <dev/ath/ath_hal/ar5212/ar5212desc.h> + +#include "ar5212_ds.h" + +#define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S ) +#define MF(_v, _f) ( !! ((_v) & (_f))) + +static void +ar5212_decode_txstatus(struct if_ath_alq_payload *a) +{ + struct ar5212_desc txs; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txs, &a->payload, sizeof(struct ar5212_desc)); + + printf("[%u] [%llu] TXSTATUS: TxDone=%d, TS=0x%08x\n\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + MF(txs.u.tx.status1, AR_Done), + MS(txs.u.tx.status0, AR_SendTimestamp)); + + /* ds_txstatus0 */ + printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n", + MF(txs.u.tx.status0, AR_FrmXmitOK), + MF(txs.u.tx.status0, AR_ExcessiveRetries), + MF(txs.u.tx.status0, AR_FIFOUnderrun), + MF(txs.u.tx.status0, AR_Filtered)); + printf(" RTScnt=%d, FailCnt=%d, VCollCnt=%d\n", + MS(txs.u.tx.status0, AR_RTSFailCnt), + MS(txs.u.tx.status0, AR_DataFailCnt), + MS(txs.u.tx.status0, AR_VirtCollCnt)); + printf(" SndTimestamp=0x%04x\n", + MS(txs.u.tx.status0, AR_SendTimestamp)); + + /* ds_txstatus1 */ + printf(" Done=%d, SeqNum=0x%04x, AckRSSI=%d, FinalTSI=%d\n", + MF(txs.u.tx.status1, AR_Done), + MS(txs.u.tx.status1, AR_SeqNum), + MS(txs.u.tx.status1, AR_AckSigStrength), + MS(txs.u.tx.status1, AR_FinalTSIndex)); + printf(" CompSuccess=%d, XmitAntenna=%d\n", + MF(txs.u.tx.status1, AR_CompSuccess), + MF(txs.u.tx.status1, AR_XmitAtenna)); + + printf("\n ------\n"); +} + +static void +ar5212_decode_txdesc(struct if_ath_alq_payload *a) +{ + struct ar5212_desc txc; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txc, &a->payload, sizeof(struct ar5212_desc)); + + printf("[%u] [%llu] TXD\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + txc.ds_link, + txc.ds_data); + + /* ds_ctl0 */ + printf(" Frame Len=%d\n", txc.ds_ctl0 & AR_FrameLen); + printf(" TX power0=%d, RtsEna=%d, Veol=%d, ClrDstMask=%d AntModeXmit=0x%02x\n", + MS(txc.ds_ctl0, AR_XmitPower), + MF(txc.ds_ctl0, AR_RTSCTSEnable), + MF(txc.ds_ctl0, AR_VEOL), + MF(txc.ds_ctl0, AR_ClearDestMask), + MF(txc.ds_ctl0, AR_AntModeXmit)); + printf(" TxIntrReq=%d, DestIdxValid=%d, CtsEnable=%d\n", + MF(txc.ds_ctl0, AR_TxInterReq), + MF(txc.ds_ctl0, AR_DestIdxValid), + MF(txc.ds_ctl0, AR_CTSEnable)); + + /* ds_ctl1 */ + printf(" BufLen=%d, TxMore=%d, DestIdx=%d," + " FrType=0x%x\n", + txc.ds_ctl1 & AR_BufLen, + MF(txc.ds_ctl1, AR_More), + MS(txc.ds_ctl1, AR_DestIdx), + MS(txc.ds_ctl1, AR_FrmType)); + printf(" NoAck=%d, CompProc=%d, CompIVLen=%d, CompICVLen=%d\n", + MF(txc.ds_ctl1, AR_NoAck), + MS(txc.ds_ctl1, AR_CompProc), + MS(txc.ds_ctl1, AR_CompIVLen), + MS(txc.ds_ctl1, AR_CompICVLen)); + + /* ds_ctl2 */ + printf(" DurUpEna=%d, Burstdur=0x%04x\n", + MF(txc.ds_ctl2, AR_DurUpdateEna), + MS(txc.ds_ctl2, AR_RTSCTSDuration)); + printf(" Try0=%d, Try1=%d, Try2=%d, Try3=%d\n", + MS(txc.ds_ctl2, AR_XmitDataTries0), + MS(txc.ds_ctl2, AR_XmitDataTries1), + MS(txc.ds_ctl2, AR_XmitDataTries2), + MS(txc.ds_ctl2, AR_XmitDataTries3)); + + /* ds_ctl3 */ + printf(" rate0=0x%02x, rate1=0x%02x, rate2=0x%02x, rate3=0x%02x\n", + MS(txc.ds_ctl3, AR_XmitRate0), + MS(txc.ds_ctl3, AR_XmitRate1), + MS(txc.ds_ctl3, AR_XmitRate2), + MS(txc.ds_ctl3, AR_XmitRate3)); + printf(" RtsCtsRate=0x%02x\n", + MS(txc.ds_ctl3, AR_RTSCTSRate)); + + printf("\n ------ \n"); +} + +static void +ar5212_decode_rxstatus(struct if_ath_alq_payload *a) +{ + struct ar5212_desc rxs; + + /* XXX assumes rxs is smaller than PAYLOAD_LEN! */ + memcpy(&rxs, &a->payload, sizeof(struct ar5212_desc)); + + printf("[%u] [%llu] RXSTATUS: RxOK=%d TS=0x%08x\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + MF(rxs.ds_rxstatus1, AR_Done), + MS(rxs.ds_rxstatus1, AR_RcvTimestamp)); + + printf(" link=0x%08x, data=0x%08x, ctl0=0x%08x, ctl2=0x%08x\n", + rxs.ds_link, + rxs.ds_data, + rxs.ds_ctl0, + rxs.ds_ctl1); + + /* ds_rxstatus0 */ + printf(" DataLen=%d, ArMore=%d, DecompCrcError=%d, RcvRate=0x%02x\n", + rxs.ds_rxstatus0 & AR_DataLen, + MF(rxs.ds_rxstatus0, AR_More), + MF(rxs.ds_rxstatus0, AR_DecompCRCErr), + MS(rxs.ds_rxstatus0, AR_RcvRate)); + printf(" RSSI=%d, RcvAntenna=0x%x\n", + MS(rxs.ds_rxstatus0, AR_RcvSigStrength), + MS(rxs.ds_rxstatus0, AR_RcvAntenna)); + + /* ds_rxstatus1 */ + printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n", + MF(rxs.ds_rxstatus1, AR_Done), + MF(rxs.ds_rxstatus1, AR_FrmRcvOK), + MF(rxs.ds_rxstatus1, AR_CRCErr), + MF(rxs.ds_rxstatus1, AR_DecryptCRCErr)); + printf(" PhyErr=%d, MichaelErr=%d, KeyIdxValid=%d\n", + MF(rxs.ds_rxstatus1, AR_PHYErr), + MF(rxs.ds_rxstatus1, AR_MichaelErr), + MF(rxs.ds_rxstatus1, AR_KeyIdxValid)); + + /* If PHY error, print that out. Otherwise, the key index */ + if (MF(rxs.ds_rxstatus1, AR_PHYErr)) + printf(" PhyErrCode=0x%02x\n", + MS(rxs.ds_rxstatus1, AR_PHYErrCode)); + else + printf(" KeyIdx=0x%02x\n", + MS(rxs.ds_rxstatus1, AR_KeyIdx)); + + printf(" KeyMiss=%d\n", + MF(rxs.ds_rxstatus1, AR_KeyCacheMiss)); + + printf(" Timetamp: 0x%05x\n", + MS(rxs.ds_rxstatus1, AR_RcvTimestamp)); + + printf("\n ------\n"); +} + +void +ar5212_alq_payload(struct if_ath_alq_payload *a) +{ + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */ + ar5212_decode_txstatus(a); + break; + case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */ + ar5212_decode_rxstatus(a); + break; + case ATH_ALQ_EDMA_TXDESC: /* TXDESC */ + ar5212_decode_txdesc(a); + break; + default: + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), be16toh(a->hdr.len)); + } +} diff --git a/tools/tools/ath/athalq/ar5212_ds.h b/tools/tools/ath/athalq/ar5212_ds.h new file mode 100644 index 0000000..508046c --- /dev/null +++ b/tools/tools/ath/athalq/ar5212_ds.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ +#ifndef __AR5212_DS_H__ +#define __AR5212_DS_H__ + +extern void ar5212_alq_payload(struct if_ath_alq_payload *a); + +#endif /* __AR5212_DS_H__ */ diff --git a/tools/tools/ath/athalq/ar5416_ds.c b/tools/tools/ath/athalq/ar5416_ds.c new file mode 100644 index 0000000..55fa1db --- /dev/null +++ b/tools/tools/ath/athalq/ar5416_ds.c @@ -0,0 +1,360 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> +#include <dev/ath/ath_hal/ar5416/ar5416desc.h> + +#include "ar5416_ds.h" + +#define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S ) +#define MF(_v, _f) ( !! ((_v) & (_f))) + +static void +ar5416_decode_txstatus(struct if_ath_alq_payload *a) +{ + struct ar5416_desc txs; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txs, &a->payload, sizeof(struct ar5416_desc)); + + printf("[%u] [%llu] TXSTATUS: TxDone=%d, TS=0x%08x\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + MF(txs.u.tx.status[9], AR_TxDone), + txs.u.tx.status[2]); + + /* ds_txstatus0 */ + printf(" RX RSSI 0 [%d %d %d]\n", + MS(txs.u.tx.status[0], AR_TxRSSIAnt00), + MS(txs.u.tx.status[0], AR_TxRSSIAnt01), + MS(txs.u.tx.status[0], AR_TxRSSIAnt02)); + printf(" BA Valid=%d\n", + MF(txs.u.tx.status[0], AR_TxBaStatus)); + + /* ds_txstatus1 */ + printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n", + MF(txs.u.tx.status[1], AR_FrmXmitOK), + MF(txs.u.tx.status[1], AR_ExcessiveRetries), + MF(txs.u.tx.status[1], AR_FIFOUnderrun), + MF(txs.u.tx.status[1], AR_Filtered)); + printf(" DelimUnderrun=%d, DataUnderun=%d, DescCfgErr=%d," + " TxTimerExceeded=%d\n", + MF(txs.u.tx.status[1], AR_TxDelimUnderrun), + MF(txs.u.tx.status[1], AR_TxDataUnderrun), + MF(txs.u.tx.status[1], AR_DescCfgErr), + MF(txs.u.tx.status[1], AR_TxTimerExpired)); + + printf(" RTScnt=%d, FailCnt=%d, VRetryCnt=%d\n", + MS(txs.u.tx.status[1], AR_RTSFailCnt), + MS(txs.u.tx.status[1], AR_DataFailCnt), + MS(txs.u.tx.status[1], AR_VirtRetryCnt)); + + /* ds_txstatus2 */ + printf(" TxTimestamp=0x%08x\n", txs.u.tx.status[2]); + + /* ds_txstatus3 */ + /* ds_txstatus4 */ + printf(" BALow=0x%08x\n", txs.u.tx.status[3]); + printf(" BAHigh=0x%08x\n", txs.u.tx.status[4]); + + /* ds_txstatus5 */ + printf(" RX RSSI 1 [%d %d %d] Comb=%d\n", + MS(txs.u.tx.status[5], AR_TxRSSIAnt10), + MS(txs.u.tx.status[5], AR_TxRSSIAnt11), + MS(txs.u.tx.status[5], AR_TxRSSIAnt12), + MS(txs.u.tx.status[5], AR_TxRSSICombined)); + + /* ds_txstatus6 */ + /* ds_txstatus7 */ + /* ds_txstatus8 */ + printf(" TxEVM[0]=0x%08x, TxEVM[1]=0x%08x, TxEVM[2]=0x%08x\n", + txs.u.tx.status[6], + txs.u.tx.status[7], + txs.u.tx.status[8]); + + /* ds_txstatus9 */ + printf(" TxDone=%d, SeqNum=0x%04x, TxOpExceeded=%d, FinalTsIdx=%d\n", + MF(txs.u.tx.status[9], AR_TxDone), + MS(txs.u.tx.status[9], AR_SeqNum), + MF(txs.u.tx.status[9], AR_TxOpExceeded), + MS(txs.u.tx.status[9], AR_FinalTxIdx)); + printf(" PowerMgmt=%d, TxTid=%d\n", + MF(txs.u.tx.status[9], AR_PowerMgmt), + MS(txs.u.tx.status[9], AR_TxTid)); + + printf("\n ------\n"); +} + +static void +ar5416_decode_txdesc(struct if_ath_alq_payload *a) +{ + struct ar5416_desc txc; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txc, &a->payload, sizeof(struct ar5416_desc)); + + printf("[%u] [%llu] TXD\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + + printf(" link=0x%08x, data=0x%08x\n", + txc.ds_link, + txc.ds_data); + + /* ds_ctl0 */ + printf(" Frame Len=%d, VMF=%d\n", + txc.ds_ctl0 & AR_FrameLen, + MF(txc.ds_ctl0, AR_VirtMoreFrag)); + printf(" TX power0=%d, RtsEna=%d, Veol=%d, ClrDstMask=%d\n", + MS(txc.ds_ctl0, AR_XmitPower), + MF(txc.ds_ctl0, AR_RTSEnable), + MF(txc.ds_ctl0, AR_VEOL), + MF(txc.ds_ctl0, AR_ClrDestMask)); + printf(" TxIntrReq=%d, DestIdxValid=%d, CtsEnable=%d\n", + MF(txc.ds_ctl0, AR_TxIntrReq), + MF(txc.ds_ctl0, AR_DestIdxValid), + MF(txc.ds_ctl0, AR_CTSEnable)); + + /* ds_ctl1 */ + printf(" BufLen=%d, TxMore=%d, DestIdx=%d," + " FrType=0x%x\n", + txc.ds_ctl1 & AR_BufLen, + MF(txc.ds_ctl1, AR_TxMore), + MS(txc.ds_ctl1, AR_DestIdx), + MS(txc.ds_ctl1, AR_FrameType)); + printf(" NoAck=%d, InsertTs=%d, CorruptFcs=%d, ExtOnly=%d," + " ExtAndCtl=%d\n", + MF(txc.ds_ctl1, AR_NoAck), + MF(txc.ds_ctl1, AR_InsertTS), + MF(txc.ds_ctl1, AR_CorruptFCS), + MF(txc.ds_ctl1, AR_ExtOnly), + MF(txc.ds_ctl1, AR_ExtAndCtl)); + printf(" MoreAggr=%d, IsAggr=%d, MoreRifs=%d\n", + MF(txc.ds_ctl1, AR_MoreAggr), + MF(txc.ds_ctl1, AR_IsAggr), + MF(txc.ds_ctl1, AR_MoreRifs)); + + /* ds_ctl2 */ + printf(" DurUpEna=%d, Burstdur=0x%04x\n", + MF(txc.ds_ctl2, AR_DurUpdateEn), + MS(txc.ds_ctl2, AR_BurstDur)); + printf(" Try0=%d, Try1=%d, Try2=%d, Try3=%d\n", + MS(txc.ds_ctl2, AR_XmitDataTries0), + MS(txc.ds_ctl2, AR_XmitDataTries1), + MS(txc.ds_ctl2, AR_XmitDataTries2), + MS(txc.ds_ctl2, AR_XmitDataTries3)); + + /* ds_ctl3 */ + printf(" rate0=0x%02x, rate1=0x%02x, rate2=0x%02x, rate3=0x%02x\n", + MS(txc.ds_ctl3, AR_XmitRate0), + MS(txc.ds_ctl3, AR_XmitRate1), + MS(txc.ds_ctl3, AR_XmitRate2), + MS(txc.ds_ctl3, AR_XmitRate3)); + + /* ds_ctl4 */ + printf(" try 0: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl4, AR_PacketDur0), + MF(txc.ds_ctl4, AR_RTSCTSQual0)); + printf(" try 1: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl4, AR_PacketDur1), + MF(txc.ds_ctl4, AR_RTSCTSQual1)); + + /* ds_ctl5 */ + printf(" try 2: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl5, AR_PacketDur2), + MF(txc.ds_ctl5, AR_RTSCTSQual2)); + printf(" try 3: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl5, AR_PacketDur3), + MF(txc.ds_ctl5, AR_RTSCTSQual3)); + + /* ds_ctl6 */ + printf(" AggrLen=%d, PadDelim=%d, EncrType=%d\n", + MS(txc.ds_ctl6, AR_AggrLen), + MS(txc.ds_ctl6, AR_PadDelim), + MS(txc.ds_ctl6, AR_EncrType)); + + /* ds_ctl7 */ + printf(" try 0: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel0), + MF(txc.ds_ctl7, AR_GI0), + MF(txc.ds_ctl7, AR_2040_0), + MF(txc.ds_ctl7, AR_STBC0)); + printf(" try 1: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel1), + MF(txc.ds_ctl7, AR_GI1), + MF(txc.ds_ctl7, AR_2040_1), + MF(txc.ds_ctl7, AR_STBC1)); + printf(" try 2: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel2), + MF(txc.ds_ctl7, AR_GI2), + MF(txc.ds_ctl7, AR_2040_2), + MF(txc.ds_ctl7, AR_STBC2)); + printf(" try 3: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel3), + MF(txc.ds_ctl7, AR_GI3), + MF(txc.ds_ctl7, AR_2040_3), + MF(txc.ds_ctl7, AR_STBC3)); + + /* ds_ctl8 */ + printf(" try 0: ant=0x%08x\n", txc.ds_ctl8 & AR_AntCtl0); + + /* ds_ctl9 */ + printf(" try 1: TxPower=%d, ant=0x%08x\n", + MS(txc.ds_ctl9, AR_XmitPower1), + txc.ds_ctl9 & AR_AntCtl1); + + /* ds_ctl10 */ + printf(" try 2: TxPower=%d, ant=0x%08x\n", + MS(txc.ds_ctl10, AR_XmitPower2), + txc.ds_ctl10 & AR_AntCtl2); + + /* ds_ctl11 */ + printf(" try 3: TxPower=%d, ant=0x%08x\n", + MS(txc.ds_ctl11, AR_XmitPower3), + txc.ds_ctl11 & AR_AntCtl3); + + printf("\n ------ \n"); +} + +static void +ar5416_decode_rxstatus(struct if_ath_alq_payload *a) +{ + struct ar5416_desc rxs; + + /* XXX assumes rxs is smaller than PAYLOAD_LEN! */ + memcpy(&rxs, &a->payload, sizeof(struct ar5416_desc)); + + printf("[%u] [%llu] RXSTATUS: RxDone=%d, TS=0x%08x\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + MF(rxs.ds_rxstatus8, AR_RxDone), + rxs.ds_rxstatus2); + + printf(" link=0x%08x, data=0x%08x, ctl0=0x%08x, ctl2=0x%08x\n", + rxs.ds_link, + rxs.ds_data, + rxs.ds_ctl0, + rxs.ds_ctl1); + + /* status0 */ + /* + * XXX TODO: For AR9285, the chain 1 and chain 2 RSSI values + * acutally contain the RX mixer configuration + */ + printf(" RSSICtl[0]=%d, RSSICtl[1]=%d, RSSICtl[2]=%d\n", + MS(rxs.ds_rxstatus0, AR_RxRSSIAnt00), + MS(rxs.ds_rxstatus0, AR_RxRSSIAnt01), + MS(rxs.ds_rxstatus0, AR_RxRSSIAnt02)); + + /* status1 */ + printf(" DataLen=%d, RxMore=%d, NumDelim=%d\n", + rxs.ds_rxstatus1 & AR_DataLen, + MF(rxs.ds_rxstatus1, AR_RxMore), + MS(rxs.ds_rxstatus1, AR_NumDelim)); + + /* status2 */ + printf(" RxTimestamp=0x%08x\n", rxs.ds_rxstatus2); + + /* status3 - RxRate however is for Owl 2.0 */ + printf(" GI=%d, 2040=%d, RxRate=0x%02x, DupFrame=%d, RxAnt=0x%08x\n", + MF(rxs.ds_rxstatus3, AR_GI), + MF(rxs.ds_rxstatus3, AR_2040), + MS(rxs.ds_rxstatus0, AR_RxRate), + MF(rxs.ds_rxstatus3, AR_DupFrame), + MS(rxs.ds_rxstatus3, AR_RxAntenna)); + + /* status4 */ + printf(" RSSIExt[0]=%d, RSSIExt[1]=%d, RSSIExt[2]=%d, RSSIComb=%d\n", + MS(rxs.ds_rxstatus4, AR_RxRSSIAnt10), + MS(rxs.ds_rxstatus4, AR_RxRSSIAnt11), + MS(rxs.ds_rxstatus4, AR_RxRSSIAnt12), + MS(rxs.ds_rxstatus4, AR_RxRSSICombined)); + + /* status5 */ + /* status6 */ + /* status7 */ + printf(" RxEvm0=0x%08x, RxEvm1=0x%08x, RxEvm2=0x%08x\n", + rxs.ds_rxstatus5, + rxs.ds_rxstatus6, + rxs.ds_rxstatus7); + + /* status8 */ + printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n", + MF(rxs.ds_rxstatus8, AR_RxDone), + MF(rxs.ds_rxstatus8, AR_RxFrameOK), + MF(rxs.ds_rxstatus8, AR_CRCErr), + MF(rxs.ds_rxstatus8, AR_DecryptCRCErr)); + printf(" PhyErr=%d, MichaelErr=%d, PreDelimCRCErr=%d, KeyIdxValid=%d\n", + MF(rxs.ds_rxstatus8, AR_PHYErr), + MF(rxs.ds_rxstatus8, AR_MichaelErr), + MF(rxs.ds_rxstatus8, AR_PreDelimCRCErr), + MF(rxs.ds_rxstatus8, AR_RxKeyIdxValid)); + + /* If PHY error, print that out. Otherwise, the key index */ + if (MF(rxs.ds_rxstatus8, AR_PHYErr)) + printf(" PhyErrCode=0x%02x\n", + MS(rxs.ds_rxstatus8, AR_PHYErrCode)); + else + printf(" KeyIdx=0x%02x\n", + MS(rxs.ds_rxstatus8, AR_KeyIdx)); + + printf(" RxMoreAggr=%d, RxAggr=%d, PostDelimCRCErr=%d, HiRxChain=%d\n", + MF(rxs.ds_rxstatus8, AR_RxMoreAggr), + MF(rxs.ds_rxstatus8, AR_RxAggr), + MF(rxs.ds_rxstatus8, AR_PostDelimCRCErr), + MF(rxs.ds_rxstatus8, AR_HiRxChain)); + printf(" KeyMiss=%d\n", + MF(rxs.ds_rxstatus8, AR_KeyMiss)); + + printf("\n ------\n"); +} + +void +ar5416_alq_payload(struct if_ath_alq_payload *a) +{ + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */ + ar5416_decode_txstatus(a); + break; + case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */ + ar5416_decode_rxstatus(a); + break; + case ATH_ALQ_EDMA_TXDESC: /* TXDESC */ + ar5416_decode_txdesc(a); + break; + default: + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), be16toh(a->hdr.len)); + } +} diff --git a/tools/tools/ath/athalq/ar5416_ds.h b/tools/tools/ath/athalq/ar5416_ds.h new file mode 100644 index 0000000..76d8163 --- /dev/null +++ b/tools/tools/ath/athalq/ar5416_ds.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ +#ifndef __AR5416_DS_H__ +#define __AR5416_DS_H__ + +extern void ar5416_alq_payload(struct if_ath_alq_payload *a); + +#endif /* __AR5416_DS_H__ */ diff --git a/tools/tools/ath/athalq/ar5416_ds_tdma.c b/tools/tools/ath/athalq/ar5416_ds_tdma.c new file mode 100644 index 0000000..42a61cb --- /dev/null +++ b/tools/tools/ath/athalq/ar5416_ds_tdma.c @@ -0,0 +1,470 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> +#include <dev/ath/ath_hal/ar5416/ar5416desc.h> + +#include "ar5416_ds.h" + +#define MS(_v, _f) ( ((_v) & (_f)) >> _f##_S ) +#define MF(_v, _f) ( !! ((_v) & (_f))) + +static void +ar5416_decode_txstatus(struct if_ath_alq_payload *a) +{ + struct ar5416_desc txs; + static uint64_t tx_tsf = 0; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txs, &a->payload, sizeof(struct ar5416_desc)); + + if (MF(txs.u.tx.status[9], AR_TxDone) == 0) + return; + + printf("[%u] [%llu] TXSTATUS: TxDone=%d, TS=0x%08x (delta %d)\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + MF(txs.u.tx.status[9], AR_TxDone), + txs.u.tx.status[2], + txs.u.tx.status[2] - tx_tsf); + + tx_tsf = txs.u.tx.status[2]; + +#if 0 + /* ds_txstatus0 */ + printf(" RX RSSI 0 [%d %d %d]\n", + MS(txs.u.tx.status[0], AR_TxRSSIAnt00), + MS(txs.u.tx.status[0], AR_TxRSSIAnt01), + MS(txs.u.tx.status[0], AR_TxRSSIAnt02)); + printf(" BA Valid=%d\n", + MF(txs.u.tx.status[0], AR_TxBaStatus)); + + /* ds_txstatus1 */ + printf(" Frmok=%d, xretries=%d, fifounderrun=%d, filt=%d\n", + MF(txs.u.tx.status[1], AR_FrmXmitOK), + MF(txs.u.tx.status[1], AR_ExcessiveRetries), + MF(txs.u.tx.status[1], AR_FIFOUnderrun), + MF(txs.u.tx.status[1], AR_Filtered)); + printf(" DelimUnderrun=%d, DataUnderun=%d, DescCfgErr=%d," + " TxTimerExceeded=%d\n", + MF(txs.u.tx.status[1], AR_TxDelimUnderrun), + MF(txs.u.tx.status[1], AR_TxDataUnderrun), + MF(txs.u.tx.status[1], AR_DescCfgErr), + MF(txs.u.tx.status[1], AR_TxTimerExpired)); + + printf(" RTScnt=%d, FailCnt=%d, VRetryCnt=%d\n", + MS(txs.u.tx.status[1], AR_RTSFailCnt), + MS(txs.u.tx.status[1], AR_DataFailCnt), + MS(txs.u.tx.status[1], AR_VirtRetryCnt)); + + /* ds_txstatus2 */ + printf(" TxTimestamp=0x%08x\n", txs.u.tx.status[2]); + + /* ds_txstatus3 */ + /* ds_txstatus4 */ + printf(" BALow=0x%08x\n", txs.u.tx.status[3]); + printf(" BAHigh=0x%08x\n", txs.u.tx.status[4]); + + /* ds_txstatus5 */ + printf(" RX RSSI 1 [%d %d %d] Comb=%d\n", + MS(txs.u.tx.status[5], AR_TxRSSIAnt10), + MS(txs.u.tx.status[5], AR_TxRSSIAnt11), + MS(txs.u.tx.status[5], AR_TxRSSIAnt12), + MS(txs.u.tx.status[5], AR_TxRSSICombined)); + + /* ds_txstatus6 */ + /* ds_txstatus7 */ + /* ds_txstatus8 */ + printf(" TxEVM[0]=0x%08x, TxEVM[1]=0x%08x, TxEVM[2]=0x%08x\n", + txs.u.tx.status[6], + txs.u.tx.status[7], + txs.u.tx.status[8]); + + /* ds_txstatus9 */ + printf(" TxDone=%d, SeqNum=0x%04x, TxOpExceeded=%d, FinalTsIdx=%d\n", + MF(txs.u.tx.status[9], AR_TxDone), + MS(txs.u.tx.status[9], AR_SeqNum), + MF(txs.u.tx.status[9], AR_TxOpExceeded), + MS(txs.u.tx.status[9], AR_FinalTxIdx)); + printf(" PowerMgmt=%d, TxTid=%d\n", + MF(txs.u.tx.status[9], AR_PowerMgmt), + MS(txs.u.tx.status[9], AR_TxTid)); + + printf("\n ------\n"); +#endif +} + +static void +ar5416_decode_txdesc(struct if_ath_alq_payload *a) +{ + struct ar5416_desc txc; + + /* XXX assumes txs is smaller than PAYLOAD_LEN! */ + memcpy(&txc, &a->payload, sizeof(struct ar5416_desc)); + + printf("[%u] [%llu] TXD\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid)); + +#if 0 + printf(" link=0x%08x, data=0x%08x\n", + txc.ds_link, + txc.ds_data); + + /* ds_ctl0 */ + printf(" Frame Len=%d, VMF=%d\n", + txc.ds_ctl0 & AR_FrameLen, + MF(txc.ds_ctl0, AR_VirtMoreFrag)); + printf(" TX power0=%d, RtsEna=%d, Veol=%d, ClrDstMask=%d\n", + MS(txc.ds_ctl0, AR_XmitPower), + MF(txc.ds_ctl0, AR_RTSEnable), + MF(txc.ds_ctl0, AR_VEOL), + MF(txc.ds_ctl0, AR_ClrDestMask)); + printf(" TxIntrReq=%d, DestIdxValid=%d, CtsEnable=%d\n", + MF(txc.ds_ctl0, AR_TxIntrReq), + MF(txc.ds_ctl0, AR_DestIdxValid), + MF(txc.ds_ctl0, AR_CTSEnable)); + + /* ds_ctl1 */ + printf(" BufLen=%d, TxMore=%d, DestIdx=%d," + " FrType=0x%x\n", + txc.ds_ctl1 & AR_BufLen, + MF(txc.ds_ctl1, AR_TxMore), + MS(txc.ds_ctl1, AR_DestIdx), + MS(txc.ds_ctl1, AR_FrameType)); + printf(" NoAck=%d, InsertTs=%d, CorruptFcs=%d, ExtOnly=%d," + " ExtAndCtl=%d\n", + MF(txc.ds_ctl1, AR_NoAck), + MF(txc.ds_ctl1, AR_InsertTS), + MF(txc.ds_ctl1, AR_CorruptFCS), + MF(txc.ds_ctl1, AR_ExtOnly), + MF(txc.ds_ctl1, AR_ExtAndCtl)); + printf(" MoreAggr=%d, IsAggr=%d, MoreRifs=%d\n", + MF(txc.ds_ctl1, AR_MoreAggr), + MF(txc.ds_ctl1, AR_IsAggr), + MF(txc.ds_ctl1, AR_MoreRifs)); + + /* ds_ctl2 */ + printf(" DurUpEna=%d, Burstdur=0x%04x\n", + MF(txc.ds_ctl2, AR_DurUpdateEn), + MS(txc.ds_ctl2, AR_BurstDur)); + printf(" Try0=%d, Try1=%d, Try2=%d, Try3=%d\n", + MS(txc.ds_ctl2, AR_XmitDataTries0), + MS(txc.ds_ctl2, AR_XmitDataTries1), + MS(txc.ds_ctl2, AR_XmitDataTries2), + MS(txc.ds_ctl2, AR_XmitDataTries3)); + + /* ds_ctl3 */ + printf(" rate0=0x%02x, rate1=0x%02x, rate2=0x%02x, rate3=0x%02x\n", + MS(txc.ds_ctl3, AR_XmitRate0), + MS(txc.ds_ctl3, AR_XmitRate1), + MS(txc.ds_ctl3, AR_XmitRate2), + MS(txc.ds_ctl3, AR_XmitRate3)); + + /* ds_ctl4 */ + printf(" try 0: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl4, AR_PacketDur0), + MF(txc.ds_ctl4, AR_RTSCTSQual0)); + printf(" try 1: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl4, AR_PacketDur1), + MF(txc.ds_ctl4, AR_RTSCTSQual1)); + + /* ds_ctl5 */ + printf(" try 2: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl5, AR_PacketDur2), + MF(txc.ds_ctl5, AR_RTSCTSQual2)); + printf(" try 3: PktDur=%d, RTS/CTS ena=%d\n", + MS(txc.ds_ctl5, AR_PacketDur3), + MF(txc.ds_ctl5, AR_RTSCTSQual3)); + + /* ds_ctl6 */ + printf(" AggrLen=%d, PadDelim=%d, EncrType=%d\n", + MS(txc.ds_ctl6, AR_AggrLen), + MS(txc.ds_ctl6, AR_PadDelim), + MS(txc.ds_ctl6, AR_EncrType)); + + /* ds_ctl7 */ + printf(" try 0: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel0), + MF(txc.ds_ctl7, AR_GI0), + MF(txc.ds_ctl7, AR_2040_0), + MF(txc.ds_ctl7, AR_STBC0)); + printf(" try 1: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel1), + MF(txc.ds_ctl7, AR_GI1), + MF(txc.ds_ctl7, AR_2040_1), + MF(txc.ds_ctl7, AR_STBC1)); + printf(" try 2: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel2), + MF(txc.ds_ctl7, AR_GI2), + MF(txc.ds_ctl7, AR_2040_2), + MF(txc.ds_ctl7, AR_STBC2)); + printf(" try 3: chainMask=0x%x, GI=%d, 2040=%d, STBC=%d\n", + MS(txc.ds_ctl7, AR_ChainSel3), + MF(txc.ds_ctl7, AR_GI3), + MF(txc.ds_ctl7, AR_2040_3), + MF(txc.ds_ctl7, AR_STBC3)); + + /* ds_ctl8 */ + printf(" try 0: ant=0x%08x\n", txc.ds_ctl8 & AR_AntCtl0); + + /* ds_ctl9 */ + printf(" try 1: TxPower=%d, ant=0x%08x\n", + MS(txc.ds_ctl9, AR_XmitPower1), + txc.ds_ctl9 & AR_AntCtl1); + + /* ds_ctl10 */ + printf(" try 2: TxPower=%d, ant=0x%08x\n", + MS(txc.ds_ctl10, AR_XmitPower2), + txc.ds_ctl10 & AR_AntCtl2); + + /* ds_ctl11 */ + printf(" try 3: TxPower=%d, ant=0x%08x\n", + MS(txc.ds_ctl11, AR_XmitPower3), + txc.ds_ctl11 & AR_AntCtl3); + + printf("\n ------ \n"); +#endif +} + +static void +ar5416_decode_rxstatus(struct if_ath_alq_payload *a) +{ + struct ar5416_desc rxs; + static uint64_t rx_tsf = 0; + + /* XXX assumes rxs is smaller than PAYLOAD_LEN! */ + memcpy(&rxs, &a->payload, sizeof(struct ar5416_desc)); + + if (MF(rxs.ds_rxstatus8, AR_RxDone) == 0) + return; + + printf("[%u] [%llu] RXSTATUS: RxDone=%d, TS=0x%08x (delta %d)\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + MF(rxs.ds_rxstatus8, AR_RxDone), + rxs.ds_rxstatus2, + rxs.ds_rxstatus2 - rx_tsf); + + rx_tsf = rxs.ds_rxstatus2; + +#if 0 + printf(" link=0x%08x, data=0x%08x, ctl0=0x%08x, ctl2=0x%08x\n", + rxs.ds_link, + rxs.ds_data, + rxs.ds_ctl0, + rxs.ds_ctl1); + + /* status0 */ + /* + * XXX TODO: For AR9285, the chain 1 and chain 2 RSSI values + * acutally contain the RX mixer configuration + */ + printf(" RSSICtl[0]=%d, RSSICtl[1]=%d, RSSICtl[2]=%d\n", + MS(rxs.ds_rxstatus0, AR_RxRSSIAnt00), + MS(rxs.ds_rxstatus0, AR_RxRSSIAnt01), + MS(rxs.ds_rxstatus0, AR_RxRSSIAnt02)); + + /* status1 */ + printf(" DataLen=%d, RxMore=%d, NumDelim=%d\n", + rxs.ds_rxstatus1 & AR_DataLen, + MF(rxs.ds_rxstatus1, AR_RxMore), + MS(rxs.ds_rxstatus1, AR_NumDelim)); + + /* status2 */ + printf(" RxTimestamp=0x%08x\n", rxs.ds_rxstatus2); + + /* status3 - RxRate however is for Owl 2.0 */ + printf(" GI=%d, 2040=%d, RxRate=0x%02x, DupFrame=%d, RxAnt=0x%08x\n", + MF(rxs.ds_rxstatus3, AR_GI), + MF(rxs.ds_rxstatus3, AR_2040), + MS(rxs.ds_rxstatus0, AR_RxRate), + MF(rxs.ds_rxstatus3, AR_DupFrame), + MS(rxs.ds_rxstatus3, AR_RxAntenna)); + + /* status4 */ + printf(" RSSIExt[0]=%d, RSSIExt[1]=%d, RSSIExt[2]=%d, RSSIComb=%d\n", + MS(rxs.ds_rxstatus4, AR_RxRSSIAnt10), + MS(rxs.ds_rxstatus4, AR_RxRSSIAnt11), + MS(rxs.ds_rxstatus4, AR_RxRSSIAnt12), + MS(rxs.ds_rxstatus4, AR_RxRSSICombined)); + + /* status5 */ + /* status6 */ + /* status7 */ + printf(" RxEvm0=0x%08x, RxEvm1=0x%08x, RxEvm2=0x%08x\n", + rxs.ds_rxstatus5, + rxs.ds_rxstatus6, + rxs.ds_rxstatus7); + + /* status8 */ + printf(" RxDone=%d, RxFrameOk=%d, CrcErr=%d, DecryptCrcErr=%d\n", + MF(rxs.ds_rxstatus8, AR_RxDone), + MF(rxs.ds_rxstatus8, AR_RxFrameOK), + MF(rxs.ds_rxstatus8, AR_CRCErr), + MF(rxs.ds_rxstatus8, AR_DecryptCRCErr)); + printf(" PhyErr=%d, MichaelErr=%d, PreDelimCRCErr=%d, KeyIdxValid=%d\n", + MF(rxs.ds_rxstatus8, AR_PHYErr), + MF(rxs.ds_rxstatus8, AR_MichaelErr), + MF(rxs.ds_rxstatus8, AR_PreDelimCRCErr), + MF(rxs.ds_rxstatus8, AR_RxKeyIdxValid)); + + /* If PHY error, print that out. Otherwise, the key index */ + if (MF(rxs.ds_rxstatus8, AR_PHYErr)) + printf(" PhyErrCode=0x%02x\n", + MS(rxs.ds_rxstatus8, AR_PHYErrCode)); + else + printf(" KeyIdx=0x%02x\n", + MS(rxs.ds_rxstatus8, AR_KeyIdx)); + + printf(" RxMoreAggr=%d, RxAggr=%d, PostDelimCRCErr=%d, HiRxChain=%d\n", + MF(rxs.ds_rxstatus8, AR_RxMoreAggr), + MF(rxs.ds_rxstatus8, AR_RxAggr), + MF(rxs.ds_rxstatus8, AR_PostDelimCRCErr), + MF(rxs.ds_rxstatus8, AR_HiRxChain)); + printf(" KeyMiss=%d\n", + MF(rxs.ds_rxstatus8, AR_KeyMiss)); + + printf("\n ------\n"); +#endif +} + +static void +ath_tdma_beacon_state(struct if_ath_alq_payload *a) +{ + struct if_ath_alq_tdma_beacon_state t; + static uint64_t last_beacon_tx = 0; + + memcpy(&t, &a->payload, sizeof(t)); + + printf("[%u] [%llu] BEACON: RX TSF=%llu Beacon TSF=%llu (%d)\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + (unsigned long long) be64toh(t.rx_tsf), + (unsigned long long) be64toh(t.beacon_tsf), + be64toh(t.beacon_tsf) - last_beacon_tx); + + last_beacon_tx = be64toh(t.beacon_tsf); +} + +static void +ath_tdma_timer_config(struct if_ath_alq_payload *a) +{ + struct if_ath_alq_tdma_timer_config t; + + memcpy(&t, &a->payload, sizeof(t)); +} + +static void +ath_tdma_slot_calc(struct if_ath_alq_payload *a) +{ + struct if_ath_alq_tdma_slot_calc t; + + memcpy(&t, &a->payload, sizeof(t)); + printf("[%u] [%llu] SLOTCALC: NEXTTBTT=%llu nextslot=%llu tsfdelta=%d avg (%d/%d)\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + (unsigned long long) be64toh(t.nexttbtt), + (unsigned long long) be64toh(t.next_slot), + (int) be32toh(t.tsfdelta), + (int) be32toh(t.avg_plus), + (int) be32toh(t.avg_minus)); +} + +static void +ath_tdma_tsf_adjust(struct if_ath_alq_payload *a) +{ + struct if_ath_alq_tdma_tsf_adjust t; + + memcpy(&t, &a->payload, sizeof(t)); + printf("[%u] [%llu] TSFADJUST: TSF64 was %llu, adj=%d, now %llu\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + (unsigned long long) be64toh(t.tsf64_old), + (int) be32toh(t.tsfdelta), + (unsigned long long) be64toh(t.tsf64_new)); +} + +static void +ath_tdma_timer_set(struct if_ath_alq_payload *a) +{ + struct if_ath_alq_tdma_timer_set t; + + memcpy(&t, &a->payload, sizeof(t)); + printf("[%u] [%llu] TIMERSET: bt_intval=%d nexttbtt=%d nextdba=%d nextswba=%d nextatim=%d flags=0x%x tdmadbaprep=%d tdmaswbaprep=%d\n", + (unsigned int) be32toh(a->hdr.tstamp), + (unsigned long long) be64toh(a->hdr.threadid), + be32toh(t.bt_intval), + be32toh(t.bt_nexttbtt), + be32toh(t.bt_nextdba), + be32toh(t.bt_nextswba), + be32toh(t.bt_nextatim), + be32toh(t.bt_flags), + be32toh(t.sc_tdmadbaprep), + be32toh(t.sc_tdmaswbaprep)); +} + +void +ar5416_alq_payload(struct if_ath_alq_payload *a) +{ + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_EDMA_TXSTATUS: /* TXSTATUS */ + ar5416_decode_txstatus(a); + break; + case ATH_ALQ_EDMA_RXSTATUS: /* RXSTATUS */ + ar5416_decode_rxstatus(a); + break; + case ATH_ALQ_EDMA_TXDESC: /* TXDESC */ + ar5416_decode_txdesc(a); + break; + case ATH_ALQ_TDMA_BEACON_STATE: + ath_tdma_beacon_state(a); + break; + case ATH_ALQ_TDMA_TIMER_CONFIG: + ath_tdma_timer_config(a); + break; + case ATH_ALQ_TDMA_SLOT_CALC: + ath_tdma_slot_calc(a); + break; + case ATH_ALQ_TDMA_TSF_ADJUST: + ath_tdma_tsf_adjust(a); + break; + case ATH_ALQ_TDMA_TIMER_SET: + ath_tdma_timer_set(a); + break; + default: + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), be16toh(a->hdr.len)); + } +} diff --git a/tools/tools/ath/athalq/main.c b/tools/tools/ath/athalq/main.c new file mode 100644 index 0000000..28bbb51 --- /dev/null +++ b/tools/tools/ath/athalq/main.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2012 Adrian Chadd <adrian@FreeBSD.org> + * All Rights Reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/alq.h> +#include <sys/endian.h> + +#include <dev/ath/if_ath_alq.h> + +#if 0 +#include "ar9300_ds.h" +#endif +#include "ar5210_ds.h" +#include "ar5211_ds.h" +#include "ar5212_ds.h" +#include "ar5416_ds.h" + +#define AR5210_MAGIC 0x19980124 +#define AR5211_MAGIC 0x19570405 +#define AR5212_MAGIC 0x19541014 +#define AR5416_MAGIC 0x20065416 +#define AR9300_MAGIC 0x19741014 + +#define READBUF_SIZE 1024 + +struct if_ath_alq_init_state hdr; + +static void +ath_alq_print_hdr(struct if_ath_alq_init_state *hdr) +{ + printf("macVersion=%d.%d, PHY=%d, Magic=%08x\n", + be32toh(hdr->sc_mac_version), + be32toh(hdr->sc_mac_revision), + be32toh(hdr->sc_phy_rev), + be32toh(hdr->sc_hal_magic)); +} + +int +main(int argc, const char *argv[]) +{ + const char *file = argv[1]; + int fd; + struct if_ath_alq_payload *a; + int r; + char buf[READBUF_SIZE]; + int buflen = 0; + + if (argc < 2) { + printf("usage: %s <ahq log>\n", argv[0]); + exit(127); + } + + fd = open(file, O_RDONLY); + if (fd < 0) { + perror("open"); + exit(127); + } + + /* + * The payload structure is now no longer a fixed + * size. So, hoops are jumped through. Really + * terrible, infficient hoops. + */ + while (1) { + if (buflen < 512) { /* XXX Eww */ + r = read(fd, buf + buflen, READBUF_SIZE - buflen); + if (r <= 0) + break; + buflen += r; + //printf("read %d bytes, buflen now %d\n", r, buflen); + } + + a = (struct if_ath_alq_payload *) &buf[0]; + + /* + * XXX sanity check that len is within the left over + * size of buf. + */ + if (be16toh(a->hdr.len) > buflen) { + fprintf(stderr, "%s: len=%d, buf=%d, tsk!\n", + argv[0], be16toh(a->hdr.len), + buflen); + break; + } + + switch (be16toh(a->hdr.op)) { + case ATH_ALQ_INIT_STATE: + /* XXX should double check length! */ + memcpy(&hdr, a->payload, sizeof(hdr)); + ath_alq_print_hdr(&hdr); + break; + default: + if (be32toh(hdr.sc_hal_magic) == AR5210_MAGIC) + ar5210_alq_payload(a); + else if (be32toh(hdr.sc_hal_magic) == AR5211_MAGIC) + ar5211_alq_payload(a); + else if (be32toh(hdr.sc_hal_magic) == AR5212_MAGIC) + ar5212_alq_payload(a); + else if (be32toh(hdr.sc_hal_magic) == AR5416_MAGIC) + ar5416_alq_payload(a); +#if 0 + else if (be32toh(hdr.sc_hal_magic) == AR9300_MAGIC) + ar9300_alq_payload(a); +#endif + else + printf("[%d] [%lld] op: %d; len %d\n", + be32toh(a->hdr.tstamp), + be64toh(a->hdr.threadid), + be16toh(a->hdr.op), + be16toh(a->hdr.len)); + } + + /* + * a.len is minus the header size, so.. + */ + buflen -= (be16toh(a->hdr.len) + + sizeof(struct if_ath_alq_hdr)); + memmove(&buf[0], + &buf[be16toh(a->hdr.len) + sizeof(struct if_ath_alq_hdr)], + READBUF_SIZE - (be16toh(a->hdr.len) + + sizeof(struct if_ath_alq_hdr))); + //printf(" buflen is now %d\n", buflen); + } + close(fd); +} diff --git a/tools/tools/ath/athdebug/athdebug.c b/tools/tools/ath/athdebug/athdebug.c index 4f8f7c8..b118939 100644 --- a/tools/tools/ath/athdebug/athdebug.c +++ b/tools/tools/ath/athdebug/athdebug.c @@ -206,20 +206,20 @@ main(int argc, char *argv[]) bit = strtoul(cp, NULL, 0); else errx(1, "unknown flag %.*s", - tp-cp, cp); + (int) (tp-cp), cp); } ndebug = bit; } } while (*(cp = tp) != '\0'); } if (debug != ndebug) { - printf("%s: 0x%x => ", oid, debug); + printf("%s: 0x%llx => ", oid, (long long) debug); if (sysctlbyname(oid, NULL, NULL, &ndebug, sizeof(ndebug)) < 0) err(1, "sysctl-set(%s)", oid); - printf("0x%x", ndebug); + printf("0x%llx", (long long) ndebug); debug = ndebug; } else - printf("%s: 0x%x", oid, debug); + printf("%s: 0x%llx", oid, (long long) debug); sep = "<"; for (i = 0; i < N(flags); i++) if (debug & flags[i].bit) { diff --git a/tools/tools/ath/athdecode/main.c b/tools/tools/ath/athdecode/main.c index 1ab5c6d..701f835 100644 --- a/tools/tools/ath/athdecode/main.c +++ b/tools/tools/ath/athdecode/main.c @@ -69,7 +69,7 @@ main(int argc, char *argv[]) filename = argv[1]; fd = open(filename, O_RDONLY); if (fd < 0) - err(1, filename); + err(1, "open: %s", filename); if (fstat(fd, &sb) < 0) err(1, "fstat"); addr = mmap(0, sb.st_size, PROT_READ, MAP_PRIVATE|MAP_NOCORE, fd, 0); @@ -192,6 +192,7 @@ opmark(FILE *fd, int i, const struct athregrec *r) fprintf(fd, "mark #%u value %u/0x%x", r->reg, r->val, r->val); break; } + exit(0); } #include "ah_devid.h" @@ -302,8 +303,8 @@ register_regs(struct dumpreg *chipregs, u_int nchipregs, */ if (nr->addr == r->addr && (nr->name == r->name || - nr->name != NULL && r->name != NULL && - strcmp(nr->name, r->name) == 0)) { + (nr->name != NULL && r->name != NULL && + strcmp(nr->name, r->name) == 0))) { if (nr->srevMin < r->srevMin && (r->srevMin <= nr->srevMax && nr->srevMax+1 <= r->srevMax)) { diff --git a/tools/tools/ath/athkey/athkey.c b/tools/tools/ath/athkey/athkey.c index d254105..7604e4e 100644 --- a/tools/tools/ath/athkey/athkey.c +++ b/tools/tools/ath/athkey/athkey.c @@ -83,8 +83,8 @@ getdata(const char *arg, u_int8_t *data, size_t maxlen) } if (len > maxlen) { fprintf(stderr, - "%s: too much data in %s, max %u bytes\n", - progname, arg, maxlen); + "%s: too much data in %s, max %llu bytes\n", + progname, arg, (unsigned long long) maxlen); } data[len++] = (b0<<4) | b1; } @@ -178,7 +178,7 @@ main(int argc, char *argv[]) atd.ad_in_data = (caddr_t) &keyix; atd.ad_in_size = sizeof(u_int16_t); if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); return 0; case HAL_DIAG_SETKEY: if (argc != 3 && argc != 4) @@ -196,7 +196,7 @@ main(int argc, char *argv[]) atd.ad_in_data = (caddr_t) &setkey; atd.ad_in_size = sizeof(setkey); if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); return 0; } return -1; diff --git a/tools/tools/ath/athprom/athprom.c b/tools/tools/ath/athprom/athprom.c index 6f2b32b..e295fd1 100644 --- a/tools/tools/ath/athprom/athprom.c +++ b/tools/tools/ath/athprom/athprom.c @@ -159,7 +159,7 @@ main(int argc, char *argv[]) atd.ad_out_data = (caddr_t) &eep; atd.ad_out_size = sizeof(eep); if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); if (fd == NULL) { fd = opentemplate(DIR_TEMPLATE); if (fd == NULL) @@ -186,7 +186,7 @@ eeread(u_int16_t off) atd.ad_out_size = sizeof(eedata); atd.ad_out_data = (caddr_t) &eedata; if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); return eedata; } @@ -204,7 +204,7 @@ eewrite(uint16_t off, uint16_t value) atd.ad_out_size = 0; atd.ad_out_data = NULL; if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); } #define MAXID 128 @@ -332,7 +332,7 @@ setmode(int mode) + sizeof(EXPN_DATA_PER_CHANNEL_5112) * exp->numChannels; atd.ad_out_data = (caddr_t) malloc(atd.ad_out_size); if (ioctl(s, SIOCGATHDIAG, &atd) < 0) - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); exp->pChannels = (void *) atd.ad_out_data; exp->pDataPerChannel = (void *)((char *)atd.ad_out_data + roundup(sizeof(u_int16_t) * exp->numChannels, sizeof(u_int32_t))); diff --git a/tools/tools/ath/athratestats/main.c b/tools/tools/ath/athratestats/main.c index 4203c9b..8d146ca 100644 --- a/tools/tools/ath/athratestats/main.c +++ b/tools/tools/ath/athratestats/main.c @@ -118,9 +118,9 @@ ath_sample_stats(struct ath_ratestats *r, struct ath_rateioctl_rt *rt, uint32_t mask; int rix, y; - PRINTMSG("static_rix (%d) ratemask 0x%x\n", + PRINTMSG("static_rix (%d) ratemask 0x%llx\n", sn->static_rix, - sn->ratemask); + (long long) sn->ratemask); for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { PRINTATTR_ON(COLOR_PAIR(y+4) | A_BOLD); @@ -203,7 +203,7 @@ ath_setifname(struct ath_ratestats *r, const char *ifname) } static void -ath_setsta(struct ath_ratestats *r, const char *mac) +ath_setsta(struct ath_ratestats *r, uint8_t *mac) { memcpy(&r->re.is_u.macaddr, mac, sizeof(r->re.is_u.macaddr)); @@ -224,7 +224,7 @@ rate_node_stats(struct ath_ratestats *r, struct ether_addr *e) struct sample_node *sn = NULL; struct ath_rateioctl_rt *rt = NULL; int error = 0; - uint8_t *buf = r->re.buf; + uint8_t *buf = (uint8_t *) r->re.buf; /* * For now, hard-code the TLV order and contents. Ew! @@ -241,7 +241,7 @@ rate_node_stats(struct ath_ratestats *r, struct ether_addr *e) fprintf(stderr, "unexpected TLV len (got %d bytes, " "expected %d bytes\n", av->tlv_len, - sizeof(struct ath_rateioctl_rt)); + (int) sizeof(struct ath_rateioctl_rt)); exit(127); } rt = (void *) (buf + sizeof(struct ath_rateioctl_tlv)); @@ -260,7 +260,7 @@ rate_node_stats(struct ath_ratestats *r, struct ether_addr *e) fprintf(stderr, "unexpected TLV len (got %d bytes, " "expected %d bytes\n", av->tlv_len, - sizeof(struct sample_node)); + (int) sizeof(struct sample_node)); exit(127); } sn = (void *) (buf + sizeof(struct ath_rateioctl_tlv) + @@ -268,6 +268,8 @@ rate_node_stats(struct ath_ratestats *r, struct ether_addr *e) sizeof(struct ath_rateioctl_tlv)); ath_sample_stats(r, rt, sn); + + return (0); } static void @@ -353,7 +355,7 @@ main(int argc, char *argv[]) if (buf == NULL) err(1, "calloc"); - r.re.buf = buf; + r.re.buf = (char *) buf; r.re.len = STATS_BUF_SIZE; r.s = socket(AF_INET, SOCK_DGRAM, 0); diff --git a/tools/tools/ath/athspectral/Makefile b/tools/tools/ath/athspectral/Makefile new file mode 100644 index 0000000..8aebde6 --- /dev/null +++ b/tools/tools/ath/athspectral/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PROG= athspectral + +.include <../Makefile.inc> + +SRCS= athspectral.c +SRCS+= opt_ah.h +CLEANFILES+= opt_ah.h + +opt_ah.h: + echo "#define AH_DEBUG 1" > opt_ah.h + echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h + echo "#define AH_SUPPORT_AR5416 1" >> opt_ah.h + +.include <bsd.prog.mk> diff --git a/tools/tools/ath/athspectral/athspectral.c b/tools/tools/ath/athspectral/athspectral.c new file mode 100644 index 0000000..7bdfa2b --- /dev/null +++ b/tools/tools/ath/athspectral/athspectral.c @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2013 Adrian Chadd <adrian@FreeBSD.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY 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 "diag.h" + +#include "ah.h" +#include "ah_internal.h" + +#ifndef ATH_DEFAULT +#define ATH_DEFAULT "ath0" +#endif + +#include <getopt.h> +#include <errno.h> +#include <err.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <unistd.h> + +struct spectralhandler { + struct ath_diag atd; + int s; + struct ifreq ifr; + int ah_devid; +}; + +int +spectral_opendev(struct spectralhandler *spectral, const char *devid) +{ + HAL_REVS revs; + + spectral->s = socket(AF_INET, SOCK_DGRAM, 0); + if (spectral->s < 0) { + warn("socket"); + return 0; + } + + strncpy(spectral->atd.ad_name, devid, sizeof (spectral->atd.ad_name)); + + /* Get the hardware revision, just to verify things are working */ + spectral->atd.ad_id = HAL_DIAG_REVS; + spectral->atd.ad_out_data = (caddr_t) &revs; + spectral->atd.ad_out_size = sizeof(revs); + if (ioctl(spectral->s, SIOCGATHDIAG, &spectral->atd) < 0) { + warn(spectral->atd.ad_name); + return 0; + } + spectral->ah_devid = revs.ah_devid; + return 1; +} + +void +spectral_closedev(struct spectralhandler *spectral) +{ + close(spectral->s); + spectral->s = -1; +} + +void +spectralset(struct spectralhandler *spectral, int op, u_int32_t param) +{ + HAL_SPECTRAL_PARAM pe; + + pe.ss_fft_period = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_period = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_count = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_short_report = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_spectral_pri = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_fft_period = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_enabled = HAL_SPECTRAL_PARAM_NOVAL; + pe.ss_active = HAL_SPECTRAL_PARAM_NOVAL; + + switch (op) { + case SPECTRAL_PARAM_FFT_PERIOD: + pe.ss_fft_period = param; + break; + case SPECTRAL_PARAM_SS_PERIOD: + pe.ss_period = param; + break; + case SPECTRAL_PARAM_SS_COUNT: + pe.ss_count = param; + break; + case SPECTRAL_PARAM_SS_SHORT_RPT: + pe.ss_short_report = param; + break; + } + + spectral->atd.ad_id = SPECTRAL_CONTROL_SET_PARAMS | ATH_DIAG_IN; + spectral->atd.ad_out_data = NULL; + spectral->atd.ad_out_size = 0; + spectral->atd.ad_in_data = (caddr_t) &pe; + spectral->atd.ad_in_size = sizeof(HAL_SPECTRAL_PARAM); + if (ioctl(spectral->s, SIOCGATHSPECTRAL, &spectral->atd) < 0) + err(1, spectral->atd.ad_name); +} + +static void +spectral_get(struct spectralhandler *spectral) +{ + HAL_SPECTRAL_PARAM pe; + + spectral->atd.ad_id = SPECTRAL_CONTROL_GET_PARAMS | ATH_DIAG_DYN; + memset(&pe, 0, sizeof(pe)); + + spectral->atd.ad_in_data = NULL; + spectral->atd.ad_in_size = 0; + spectral->atd.ad_out_data = (caddr_t) &pe; + spectral->atd.ad_out_size = sizeof(pe); + + if (ioctl(spectral->s, SIOCGATHSPECTRAL, &spectral->atd) < 0) + err(1, spectral->atd.ad_name); + + printf("Spectral parameters (raw):\n"); + printf(" ss_enabled: %d\n", pe.ss_enabled); + printf(" ss_active: %d\n", pe.ss_active); + printf(" ss_count: %d\n", pe.ss_count); + printf(" ss_fft_period: %d\n", pe.ss_fft_period); + printf(" ss_period: %d\n", pe.ss_period); + printf(" ss_short_report: %d\n", pe.ss_short_report); + printf(" radar_bin_thresh_sel: %d\n", pe.radar_bin_thresh_sel); +} + +static void +spectral_start(struct spectralhandler *spectral) +{ + HAL_SPECTRAL_PARAM pe; + + spectral->atd.ad_id = SPECTRAL_CONTROL_START | ATH_DIAG_DYN; + memset(&pe, 0, sizeof(pe)); + + /* + * XXX don't need these, but need to eliminate the ATH_DIAG_DYN flag + * and debug + */ + spectral->atd.ad_in_data = NULL; + spectral->atd.ad_in_size = 0; + spectral->atd.ad_out_data = (caddr_t) &pe; + spectral->atd.ad_out_size = sizeof(pe); + + if (ioctl(spectral->s, SIOCGATHSPECTRAL, &spectral->atd) < 0) + err(1, spectral->atd.ad_name); +} + +static void +spectral_stop(struct spectralhandler *spectral) +{ + HAL_SPECTRAL_PARAM pe; + + spectral->atd.ad_id = SPECTRAL_CONTROL_STOP | ATH_DIAG_DYN; + memset(&pe, 0, sizeof(pe)); + + /* + * XXX don't need these, but need to eliminate the ATH_DIAG_DYN flag + * and debug + */ + spectral->atd.ad_in_data = NULL; + spectral->atd.ad_in_size = 0; + spectral->atd.ad_out_data = (caddr_t) &pe; + spectral->atd.ad_out_size = sizeof(pe); + + if (ioctl(spectral->s, SIOCGATHSPECTRAL, &spectral->atd) < 0) + err(1, spectral->atd.ad_name); +} + +static void +spectral_enable_at_reset(struct spectralhandler *spectral, int val) +{ + int v = val; + + spectral->atd.ad_id = SPECTRAL_CONTROL_ENABLE_AT_RESET + | ATH_DIAG_IN; + + /* + * XXX don't need these, but need to eliminate the ATH_DIAG_DYN flag + * and debug + */ + spectral->atd.ad_out_data = NULL; + spectral->atd.ad_out_size = 0; + spectral->atd.ad_in_data = (caddr_t) &v; + spectral->atd.ad_in_size = sizeof(v); + + printf("%s: val=%d\n", __func__, v); + + if (ioctl(spectral->s, SIOCGATHSPECTRAL, &spectral->atd) < 0) + err(1, spectral->atd.ad_name); +} + +static int +spectral_set_param(struct spectralhandler *spectral, const char *param, + const char *val) +{ + int v; + + v = atoi(val); + + if (strcmp(param, "ss_short_report") == 0) { + spectralset(spectral, SPECTRAL_PARAM_SS_SHORT_RPT, v); + } else if (strcmp(param, "ss_fft_period") == 0) { + spectralset(spectral, SPECTRAL_PARAM_FFT_PERIOD, v); + } else if (strcmp(param, "ss_period") == 0) { + spectralset(spectral, SPECTRAL_PARAM_SS_PERIOD, v); + } else if (strcmp(param, "ss_count") == 0) { + spectralset(spectral, SPECTRAL_PARAM_SS_COUNT, v); + } else { + return (0); + } + +#if 0 + if (strcmp(param, "enabled") == 0) { + spectralset(spectral, DFS_PARAM_ENABLE, v); + } else if (strcmp(param, "firpwr") == 0) { + spectralset(spectral, DFS_PARAM_FIRPWR, v); + } else if (strcmp(param, "rrssi") == 0) { + spectralset(spectral, DFS_PARAM_RRSSI, v); + } else if (strcmp(param, "height") == 0) { + spectralset(spectral, DFS_PARAM_HEIGHT, v); + } else if (strcmp(param, "prssi") == 0) { + spectralset(spectral, DFS_PARAM_PRSSI, v); + } else if (strcmp(param, "inband") == 0) { + spectralset(spectral, DFS_PARAM_INBAND, v); + } else if (strcmp(param, "relpwr") == 0) { + spectralset(spectral, DFS_PARAM_RELPWR, v); + } else if (strcmp(param, "relstep") == 0) { + spectralset(spectral, DFS_PARAM_RELSTEP, v); + } else if (strcmp(param, "maxlen") == 0) { + spectralset(spectral, DFS_PARAM_MAXLEN, v); + } else if (strcmp(param, "usefir128") == 0) { + spectralset(spectral, DFS_PARAM_USEFIR128, v); + } else if (strcmp(param, "blockspectral") == 0) { + spectralset(spectral, DFS_PARAM_BLOCKRADAR, v); + } else if (strcmp(param, "enmaxrssi") == 0) { + spectralset(spectral, DFS_PARAM_MAXRSSI_EN, v); + } else if (strcmp(param, "extchannel") == 0) { + spectralset(spectral, DFS_PARAM_EN_EXTCH, v); + } else if (strcmp(param, "enrelpwr") == 0) { + spectralset(spectral, DFS_PARAM_RELPWR_EN, v); + } else if (strcmp(param, "en_relstep_check") == 0) { + spectralset(spectral, DFS_PARAM_RELSTEP_EN, v); + } else { + return 0; + } +#endif + + return 1; +} + +void +usage(const char *progname) +{ + printf("Usage:\n"); + printf("\t%s: [-i <interface>] <cmd> (<arg>)\n", progname); + printf("\t%s: [-h]\n", progname); + printf("\n"); + printf("Valid commands:\n"); + printf("\tget:\t\tGet current spectral parameters\n"); + printf("\tset <param> <value>:\t\tSet spectral parameter\n"); + printf("\tstart: Start spectral scan\n"); + printf("\tstop: Stop spectral scan\n"); + printf("\tenable_at_reset <0|1>: enable reporting upon channel reset\n"); +} + +int +main(int argc, char *argv[]) +{ + struct spectralhandler spectral; + const char *devname = ATH_DEFAULT; + const char *progname = argv[0]; + + memset(&spectral, 0, sizeof(spectral)); + + /* Parse command line options */ + if (argc >= 2 && strcmp(argv[1], "-h") == 0) { + usage(progname); + exit(0); + } + if (argc >= 2 && strcmp(argv[1], "-?") == 0) { + usage(progname); + exit(0); + } + + if (argc >= 2 && strcmp(argv[1], "-i") == 0) { + if (argc == 2) { + usage(progname); + exit(127); + } + devname = argv[2]; + argc -= 2; argv += 2; + } + + /* At this point we require at least one command */ + if (argc == 1) { + usage(progname); + exit(127); + } + + if (spectral_opendev(&spectral, devname) == 0) + exit(127); + + if (strcasecmp(argv[1], "get") == 0) { + spectral_get(&spectral); + } else if (strcasecmp(argv[1], "set") == 0) { + if (argc < 4) { + usage(progname); + exit(127); + } + if (spectral_set_param(&spectral, argv[2], argv[3]) == 0) { + usage(progname); + exit(127); + } + } else if (strcasecmp(argv[1], "start") == 0) { + spectral_start(&spectral); + } else if (strcasecmp(argv[1], "stop") == 0) { + spectral_stop(&spectral); + } else if (strcasecmp(argv[1], "enable_at_reset") == 0) { + if (argc < 3) { + usage(progname); + exit(127); + } + spectral_enable_at_reset(&spectral, atoi(argv[2])); + } else { + usage(progname); + exit(127); + } + + /* wrap up */ + spectral_closedev(&spectral); + exit(0); +} diff --git a/tools/tools/ath/athstats/Makefile b/tools/tools/ath/athstats/Makefile index 4a88eb1..1db2dc1 100644 --- a/tools/tools/ath/athstats/Makefile +++ b/tools/tools/ath/athstats/Makefile @@ -4,6 +4,10 @@ PROG= athstats +# Because of a clang preprocessor parser limitation causing this +# to not compile, use gcc for now. +CC= gcc + SRCS= main.c statfoo.c athstats.c opt_ah.h ah_osdep.h CLEANFILES+= opt_ah.h diff --git a/tools/tools/ath/athstats/athstats.c b/tools/tools/ath/athstats/athstats.c index c36dfa0..ef815bd 100644 --- a/tools/tools/ath/athstats/athstats.c +++ b/tools/tools/ath/athstats/athstats.c @@ -490,7 +490,7 @@ ath_zerostats(struct athstatfoo *wf0) struct athstatfoo_p *wf = (struct athstatfoo_p *) wf0; if (ioctl(wf->s, SIOCZATHSTATS, &wf->ifr) < 0) - err(-1, wf->ifr.ifr_name); + err(-1, "ioctl: %s", wf->ifr.ifr_name); } static void @@ -498,21 +498,21 @@ ath_collect(struct athstatfoo_p *wf, struct _athstats *stats) { wf->ifr.ifr_data = (caddr_t) &stats->ath; if (ioctl(wf->s, SIOCGATHSTATS, &wf->ifr) < 0) - err(1, wf->ifr.ifr_name); + err(1, "ioctl: %s", wf->ifr.ifr_name); #ifdef ATH_SUPPORT_ANI if (wf->optstats & ATHSTATS_ANI) { wf->atd.ad_id = 5; wf->atd.ad_out_data = (caddr_t) &stats->ani_state; wf->atd.ad_out_size = sizeof(stats->ani_state); if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) { - warn(wf->atd.ad_name); + warn("ioctl: %s", wf->atd.ad_name); wf->optstats &= ~ATHSTATS_ANI; } wf->atd.ad_id = 8; wf->atd.ad_out_data = (caddr_t) &stats->ani_stats; wf->atd.ad_out_size = sizeof(stats->ani_stats); if (ioctl(wf->s, SIOCGATHDIAG, &wf->atd) < 0) - warn(wf->atd.ad_name); + warn("ioctl: %s", wf->atd.ad_name); } #endif /* ATH_SUPPORT_ANI */ } @@ -574,12 +574,14 @@ ath_get_curstat(struct statfoo *sf, int s, char b[], size_t bs) switch (s) { case S_INPUT: snprintf(b, bs, "%lu", - (wf->cur.ath.ast_rx_packets - wf->total.ath.ast_rx_packets) - - (wf->cur.ath.ast_rx_mgt - wf->total.ath.ast_rx_mgt)); + (unsigned long) + ((wf->cur.ath.ast_rx_packets - wf->total.ath.ast_rx_packets) - + (wf->cur.ath.ast_rx_mgt - wf->total.ath.ast_rx_mgt))); return 1; case S_OUTPUT: snprintf(b, bs, "%lu", - wf->cur.ath.ast_tx_packets - wf->total.ath.ast_tx_packets); + (unsigned long) + (wf->cur.ath.ast_tx_packets - wf->total.ath.ast_tx_packets)); return 1; case S_RATE: snprintrate(b, bs, wf->cur.ath.ast_tx_rate); diff --git a/tools/tools/ath/athsurvey/athsurvey.c b/tools/tools/ath/athsurvey/athsurvey.c index e0a4cf3..df2ae4d 100644 --- a/tools/tools/ath/athsurvey/athsurvey.c +++ b/tools/tools/ath/athsurvey/athsurvey.c @@ -66,7 +66,7 @@ get_survey_stats(int s, const char *ifname, HAL_CHANNEL_SURVEY *hs) strncpy(atd.ad_name, ifname, sizeof(atd.ad_name)); if (ioctl(s, SIOCGATHDIAG, &atd) < 0) { - err(1, atd.ad_name); + err(1, "ioctl: %s", atd.ad_name); return (0); } return (1); diff --git a/tools/tools/cxgbetool/cxgbetool.c b/tools/tools/cxgbetool/cxgbetool.c index 7d0faa6..39e7376 100644 --- a/tools/tools/cxgbetool/cxgbetool.c +++ b/tools/tools/cxgbetool/cxgbetool.c @@ -955,7 +955,7 @@ set_filter(uint32_t idx, int argc, const char *argv[]) t.fs.mask.vnic = mask; t.fs.val.vnic_vld = 1; t.fs.mask.vnic_vld = 1; - } else if (!parse_val_mask("vlan", args, &val, &mask)) { + } else if (!parse_val_mask("ivlan", args, &val, &mask)) { t.fs.val.vlan = val; t.fs.mask.vlan = mask; t.fs.val.vlan_vld = 1; @@ -1047,10 +1047,17 @@ set_filter(uint32_t idx, int argc, const char *argv[]) t.fs.newvlan = VLAN_REWRITE; } else if (argv[start_arg + 1][0] == '+') { t.fs.newvlan = VLAN_INSERT; + } else if (isdigit(argv[start_arg + 1][0]) && + !parse_val_mask("vlan", args, &val, &mask)) { + t.fs.val.vlan = val; + t.fs.mask.vlan = mask; + t.fs.val.vlan_vld = 1; + t.fs.mask.vlan_vld = 1; } else { warnx("unknown vlan parameter \"%s\"; must" - " be one of \"none\", \"=<vlan>\" or" - " \"+<vlan>\"", argv[start_arg + 1]); + " be one of \"none\", \"=<vlan>\", " + " \"+<vlan>\", or \"<vlan>\"", + argv[start_arg + 1]); return (EINVAL); } if (t.fs.newvlan == VLAN_REWRITE || diff --git a/tools/tools/netrate/netreceive/Makefile b/tools/tools/netrate/netreceive/Makefile index ef2b09b..33fee2b 100644 --- a/tools/tools/netrate/netreceive/Makefile +++ b/tools/tools/netrate/netreceive/Makefile @@ -4,5 +4,6 @@ PROG= netreceive NO_MAN= +LDFLAGS += -lpthread .include <bsd.prog.mk> diff --git a/tools/tools/netrate/netreceive/netreceive.c b/tools/tools/netrate/netreceive/netreceive.c index 9300109..a82cefc 100644 --- a/tools/tools/netrate/netreceive/netreceive.c +++ b/tools/tools/netrate/netreceive/netreceive.c @@ -43,27 +43,168 @@ #define MAXSOCK 20 +#include <pthread.h> +#include <fcntl.h> +#include <time.h> /* clock_getres() */ + +static int round_to(int n, int l) +{ + return ((n + l - 1)/l)*l; +} + +/* + * Each socket uses multiple threads so the receiver is + * more efficient. A collector thread runs the stats. + */ +struct td_desc { + pthread_t td_id; + uint64_t count; /* rx counter */ + uint64_t byte_count; /* rx byte counter */ + int fd; + char *buf; + int buflen; +}; + static void usage(void) { - fprintf(stderr, "netreceive [port]\n"); + fprintf(stderr, "netreceive port [nthreads]\n"); exit(-1); } +static __inline void +timespec_add(struct timespec *tsa, struct timespec *tsb) +{ + + tsa->tv_sec += tsb->tv_sec; + tsa->tv_nsec += tsb->tv_nsec; + if (tsa->tv_nsec >= 1000000000) { + tsa->tv_sec++; + tsa->tv_nsec -= 1000000000; + } +} + +static __inline void +timespec_sub(struct timespec *tsa, struct timespec *tsb) +{ + + tsa->tv_sec -= tsb->tv_sec; + tsa->tv_nsec -= tsb->tv_nsec; + if (tsa->tv_nsec < 0) { + tsa->tv_sec--; + tsa->tv_nsec += 1000000000; + } +} + +static void * +rx_body(void *data) +{ + struct td_desc *t = data; + struct pollfd fds; + int y; + + fds.fd = t->fd; + fds.events = POLLIN; + + for (;;) { + if (poll(&fds, 1, -1) < 0) + perror("poll on thread"); + if (!(fds.revents & POLLIN)) + continue; + for (;;) { + y = recv(t->fd, t->buf, t->buflen, MSG_DONTWAIT); + if (y < 0) + break; + t->count++; + t->byte_count += y; + } + } + return NULL; +} + +static struct td_desc ** +make_threads(int *s, int nsock, int nthreads) +{ + int i, si, nt = nsock * nthreads; + int lb = round_to(nt * sizeof (struct td_desc *), 64); + int td_len = round_to(sizeof(struct td_desc), 64); // cache align + char *m = calloc(1, lb + td_len * nt); + struct td_desc **tp; + + printf("td len %d -> %d\n", (int)sizeof(struct td_desc) , td_len); + /* pointers plus the structs */ + if (m == NULL) { + perror("no room for pointers!"); + exit(1); + } + tp = (struct td_desc **)m; + m += lb; /* skip the pointers */ + for (si = i = 0; i < nt; i++, m += td_len) { + tp[i] = (struct td_desc *)m; + tp[i]->fd = s[si]; + tp[i]->buflen = 65536; + tp[i]->buf = calloc(1, tp[i]->buflen); + if (++si == nsock) + si = 0; + if (pthread_create(&tp[i]->td_id, NULL, rx_body, tp[i])) { + perror("unable to create thread"); + exit(1); + } + } + return tp; +} + +static void +main_thread(struct td_desc **tp, int nsock, int nthreads) +{ + uint64_t c0, c1, bc0, bc1; + struct timespec now, then, delta; + /* now the parent collects and prints results */ + c0 = c1 = bc0 = bc1 = 0; + clock_gettime(CLOCK_REALTIME, &then); + fprintf(stderr, "start at %ld.%09ld\n", then.tv_sec, then.tv_nsec); + while (1) { + int i, nt = nsock * nthreads; + int64_t dn; + uint64_t pps, bps; + + if (poll(NULL, 0, 500) < 0) + perror("poll"); + c0 = bc0 = 0; + for (i = 0; i < nt; i++) { + c0 += tp[i]->count; + bc0 += tp[i]->byte_count; + } + dn = c0 - c1; + clock_gettime(CLOCK_REALTIME, &now); + delta = now; + timespec_sub(&delta, &then); + then = now; + pps = dn; + pps = (pps * 1000000000) / (delta.tv_sec*1000000000 + delta.tv_nsec + 1); + bps = ((bc0 - bc1) * 8000000000) / (delta.tv_sec*1000000000 + delta.tv_nsec + 1); + fprintf(stderr, " %9ld pps %8.3f Mbps", (long)pps, .000001*bps); + fprintf(stderr, " - %d pkts in %ld.%09ld ns\n", + (int)dn, delta.tv_sec, delta.tv_nsec); + c1 = c0; + bc1 = bc0; + } +} + int main(int argc, char *argv[]) { struct addrinfo hints, *res, *res0; char *dummy, *packet; int port; - int error, v, i; + int error, v, nthreads = 1; + struct td_desc **tp; const char *cause = NULL; int s[MAXSOCK]; - struct pollfd fds[MAXSOCK]; int nsock; - if (argc != 2) + if (argc < 2) usage(); memset(&hints, 0, sizeof(hints)); @@ -74,6 +215,10 @@ main(int argc, char *argv[]) port = strtoul(argv[1], &dummy, 10); if (port < 1 || port > 65535 || *dummy != '\0') usage(); + if (argc > 2) + nthreads = strtoul(argv[2], &dummy, 10); + if (nthreads < 1 || nthreads > 64) + usage(); packet = malloc(65536); if (packet == NULL) { @@ -110,9 +255,6 @@ main(int argc, char *argv[]) continue; } (void) listen(s[nsock], 5); - fds[nsock].fd = s[nsock]; - fds[nsock].events = POLLIN; - nsock++; } if (nsock == 0) { @@ -121,21 +263,12 @@ main(int argc, char *argv[]) /*NOTREACHED*/ } - printf("netreceive listening on UDP port %d\n", (u_short)port); + printf("netreceive %d sockets x %d threads listening on UDP port %d\n", + nsock, nthreads, (u_short)port); + + tp = make_threads(s, nsock, nthreads); + main_thread(tp, nsock, nthreads); - while (1) { - if (poll(fds, nsock, -1) < 0) - perror("poll"); - for (i = 0; i < nsock; i++) { - if (fds[i].revents & POLLIN) { - if (recv(s[i], packet, 65536, 0) < 0) - perror("recv"); - } - if ((fds[i].revents &~ POLLIN) != 0) - perror("poll"); - } - } - /*NOTREACHED*/ freeaddrinfo(res0); } diff --git a/tools/tools/netrate/netsend/netsend.c b/tools/tools/netrate/netsend/netsend.c index 0558253..683c823 100644 --- a/tools/tools/netrate/netsend/netsend.c +++ b/tools/tools/netrate/netsend/netsend.c @@ -144,7 +144,7 @@ timing_loop(struct _a *a) long finishtime; long send_errors, send_calls; /* do not call gettimeofday more than every 20us */ - long minres_ns = 20000; + long minres_ns = 200000; int ic, gettimeofday_cycles; int cur_port; uint64_t n, ns; @@ -154,17 +154,22 @@ timing_loop(struct _a *a) return (-1); } + ns = a->interval.tv_nsec; if (timespec_ge(&tmptime, &a->interval)) fprintf(stderr, "warning: interval (%jd.%09ld) less than resolution (%jd.%09ld)\n", (intmax_t)a->interval.tv_sec, a->interval.tv_nsec, (intmax_t)tmptime.tv_sec, tmptime.tv_nsec); - if (a->interval.tv_nsec < minres_ns) { - gettimeofday_cycles = minres_ns/(tmptime.tv_nsec + 1); - fprintf(stderr, - "calling time every %d cycles\n", gettimeofday_cycles); - } else - gettimeofday_cycles = 0; + /* interval too short, limit the number of gettimeofday() + * calls, but also make sure there is at least one every + * some 100 packets. + */ + if ((long)ns < minres_ns/100) + gettimeofday_cycles = 100; + else + gettimeofday_cycles = minres_ns/ns; + fprintf(stderr, + "calling time every %d cycles\n", gettimeofday_cycles); if (clock_gettime(CLOCK_REALTIME, &starttime) == -1) { perror("clock_gettime"); diff --git a/tools/tools/notescheck/notescheck.py b/tools/tools/notescheck/notescheck.py index 5aae296..35915b9 100644 --- a/tools/tools/notescheck/notescheck.py +++ b/tools/tools/notescheck/notescheck.py @@ -7,14 +7,16 @@ # # $FreeBSD$ +from __future__ import print_function + import glob import os.path import sys def usage(): - print >>sys.stderr, "notescheck <path>" - print >>sys.stderr - print >>sys.stderr, "Where 'path' is a path to a kernel source tree." + print("notescheck <path>", file=sys.stderr) + print(file=sys.stderr) + print("Where 'path' is a path to a kernel source tree.", file=sys.stderr) # These files are used to determine if a path is a valid kernel source tree. requiredfiles = ['conf/files', 'conf/options', 'conf/NOTES'] @@ -62,9 +64,9 @@ class Option: self.type = type self.type_location = location elif self.type != type: - print "WARN: Attempt to change type of %s from %s to %s%s" % \ - (self.name, self.type, type, location) - print " Previous type set%s" % (self.type_location) + print("WARN: Attempt to change type of %s from %s to %s%s" % \ + (self.name, self.type, type, location)) + print(" Previous type set%s" % (self.type_location)) def add_define(self, platform): self.defines.add(platform) @@ -93,8 +95,8 @@ class Option: if global_platform in self.defines: # If the device is defined globally ans is never tested, whine. if len(self.tests) == 0: - print 'WARN: %s is defined globally but never tested' % \ - (self.title()) + print('WARN: %s is defined globally but never tested' % \ + (self.title())) return # If the device is defined globally and is tested on @@ -106,25 +108,25 @@ class Option: # If a device is defined globally but is only tested on a # single MD platform, then whine about this. - print 'WARN: %s is defined globally but only tested in %s NOTES' % \ - (self.title(), format_set(self.tests)) + print('WARN: %s is defined globally but only tested in %s NOTES' % \ + (self.title(), format_set(self.tests))) return # If an option or device is never tested, whine. if len(self.tests) == 0: - print 'WARN: %s is defined in %s but never tested' % \ - (self.title(), format_set(self.defines)) + print('WARN: %s is defined in %s but never tested' % \ + (self.title(), format_set(self.defines))) return # The set of MD platforms where this option is defined, but not tested. notest = self.defines - self.tests if len(notest) != 0: - print 'WARN: %s is not tested in %s NOTES' % \ - (self.title(), format_set(notest)) + print('WARN: %s is not tested in %s NOTES' % \ + (self.title(), format_set(notest))) return - print 'ERROR: bad state for %s: defined in %s, tested in %s' % \ - (self.title(), format_set(self.defines), format_set(self.tests)) + print('ERROR: bad state for %s: defined in %s, tested in %s' % \ + (self.title(), format_set(self.defines), format_set(self.tests))) # This class maintains a dictionary of options keyed by name. class Options: @@ -143,7 +145,7 @@ class Options: # Warn about inconsistencies def warn(self): - keys = self.options.keys() + keys = list(self.options.keys()) keys.sort() for key in keys: option = self.options[key] @@ -158,11 +160,11 @@ def find_platforms(tree): platforms = [] for file in glob.glob(tree + '*/conf/NOTES'): if not file.startswith(tree): - print >>sys.stderr, "Bad MD NOTES file %s" %(file) + print("Bad MD NOTES file %s" %(file), file=sys.stderr) sys.exit(1) platforms.append(file[len(tree):].split('/')[0]) if global_platform in platforms: - print >>sys.stderr, "Found MD NOTES file for global platform" + print("Found MD NOTES file for global platform", file=sys.stderr) sys.exit(1) return platforms @@ -224,7 +226,7 @@ def tokenize(line): # will contain 'number of quotes' + 1 entries, so it should have # an odd number of entries. if len(groups) % 2 == 0: - print >>sys.stderr, "Failed to tokenize: %s%s" (line, location) + print("Failed to tokenize: %s%s" (line, location), file=sys.stderr) return [] # String split all the "odd" groups since they are not quoted strings. @@ -256,7 +258,7 @@ def parse_files_line(line, platform): # Remaining lines better be optional or mandatory lines. if words[1] != 'optional' and words[1] != 'mandatory': - print >>sys.stderr, "Invalid files line: %s%s" % (line, location) + print("Invalid files line: %s%s" % (line, location), file=sys.stderr) # Drop the first two words and begin parsing keywords and devices. skip = False @@ -334,7 +336,7 @@ def main(argv=None): tree = tree + '/' for file in requiredfiles: if not os.path.exists(tree + file): - print>> sys.stderr, "Kernel source tree missing %s" % (file) + print("Kernel source tree missing %s" % (file), file=sys.stderr) return 1 platforms = find_platforms(tree) diff --git a/tools/tools/sysbuild/sysbuild.sh b/tools/tools/sysbuild/sysbuild.sh index dfca7c0..2f91e86 100644 --- a/tools/tools/sysbuild/sysbuild.sh +++ b/tools/tools/sysbuild/sysbuild.sh @@ -225,37 +225,49 @@ ports_build() ( # Now build & install them for p in `cat /tmp/_.plist` do + b=`echo $p | tr / _` t=`echo $p | sed 's,/usr/ports/,,'` pn=`cd $p && make package-name` - if [ "x${PKG_DIR}" != "x" -a -f ${PKG_DIR}/$pn.tbz ] ; then - if [ "x$use_pkg" = "x-p" ] ; then - log_it "install $p from ${PKG_DIR}/$pn.tbz" - pkg_add ${PKG_DIR}/$pn.tbz - fi + + if pkg info $pn > /dev/null 2>&1 ; then + log_it "Already installed: $t ($pn)" + continue fi - i=`pkg_info -qO $t` - if [ -z "$i" ] ; then - log_it "build $p" - b=`echo $p | tr / _` + + if [ "x$p" == "x/usr/ports/ports-mgmt/pkg" ] ; then + log_it "Very Special: $t ($pn)" ( - set -x - cd /usr/ports - cd $p - set +e - make clean ${PORTS_OPTS} - if make install ${PORTS_OPTS} ; then - if [ "x${PKG_DIR}" != "x" ] ; then - make package ${PORTS_OPTS} - mkdir -p ${PKG_DIR} - mv *.tbz ${PKG_DIR} - fi - else - log_it FAIL build $p - fi - make clean + cd $p + make clean all install ${PORTS_OPTS} ) > _.$b 2>&1 < /dev/null - date + continue + fi + + if [ "x${PKG_DIR}" != "x" -a -f ${PKG_DIR}/$pn.txz ] ; then + if [ "x$use_pkg" = "x-p" ] ; then + log_it "Install $t ($pn)" + ( + set +e + pkg add ${PKG_DIR}/$pn.txz || true + ) > _.$b 2>&1 < /dev/null + continue + fi fi + + log_it "build $pn ($p)" + ( + set +e + cd $p + make clean ${PORTS_OPTS} + if make install ${PORTS_OPTS} ; then + if [ "x${PKG_DIR}" != "x" ] ; then + make package ${PORTS_OPTS} + fi + else + log_it FAIL build $p + fi + make clean + ) > _.$b 2>&1 < /dev/null done ) @@ -463,7 +475,7 @@ export PORTS_OPTS ####################################################################### log_it Prepare destination partition -newfs -O2 -U /dev/${TARGET_PART} > /dev/null +newfs -t -E -O2 -U /dev/${TARGET_PART} > /dev/null mount /dev/${TARGET_PART} ${SBMNT} mkdir -p ${SBMNT}/dev mount -t devfs devfs ${SBMNT}/dev @@ -564,7 +576,7 @@ sed "/[ ]\/[ ]/s;^[^ ]*[ ];/dev/${TARGET_PART} ;" \ /etc/fstab > ${SBMNT}/etc/fstab log_it build ports -pwd + cp $0 ${SBMNT}/root cp /tmp/_sb_log ${SBMNT}/tmp b=`basename $0` |