summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ObsoleteFiles.inc5
-rw-r--r--UPDATING2
-rw-r--r--bin/pkill/tests/pgrep-j_test.sh3
-rw-r--r--bin/pkill/tests/pkill-j_test.sh3
-rw-r--r--contrib/ipfilter/ip_fil.c3
-rw-r--r--contrib/ipfilter/ipf.h3
-rw-r--r--contrib/llvm/lib/Transforms/Scalar/LoopRotation.cpp2
-rw-r--r--contrib/llvm/patches/patch-08-llvm-r230058-indirectbrs-assert.diff55
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_nice.c28
-rwxr-xr-xetc/netstart1
-rw-r--r--games/Makefile2
-rw-r--r--games/bcd/Makefile9
-rw-r--r--games/bcd/bcd.652
-rw-r--r--games/bcd/bcd.c215
-rw-r--r--games/ppt/Makefile8
-rw-r--r--games/ppt/ppt.c82
-rw-r--r--lib/libc/db/man/dbm.36
-rw-r--r--lib/libc/gen/getgrent.c4
-rw-r--r--lib/libc/gen/getpwent.c4
-rw-r--r--lib/libc/gen/nice.325
-rw-r--r--lib/libc/gen/nice.c12
-rw-r--r--lib/libc/gen/setmode.c4
-rw-r--r--lib/libc/regex/engine.c4
-rw-r--r--lib/libc/regex/regcomp.c4
-rw-r--r--lib/msun/src/e_j0.c2
-rw-r--r--lib/msun/src/e_j0f.c2
-rw-r--r--lib/msun/src/e_j1.c2
-rw-r--r--lib/msun/src/e_j1f.c2
-rw-r--r--release/doc/en_US.ISO8859-1/relnotes/article.xml64
-rw-r--r--release/release.conf.sample3
-rwxr-xr-xrelease/release.sh3
-rw-r--r--share/man/man4/Makefile4
-rw-r--r--share/man/man4/man4.arm/devcfg.42
-rw-r--r--share/man/man4/man4.i386/apm.42
-rw-r--r--share/man/man4/man4.powerpc/Makefile1
-rw-r--r--share/man/man4/man4.powerpc/llan.461
-rw-r--r--share/man/man4/man4.powerpc/tsec.421
-rw-r--r--share/man/man5/rc.conf.522
-rw-r--r--share/man/man7/release.711
-rw-r--r--share/man/man9/microuptime.93
-rw-r--r--share/misc/committers-doc.dot2
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_mbox.c71
-rw-r--r--sys/arm/include/atomic.h4
-rw-r--r--sys/boot/efi/include/amd64/efibind.h4
-rw-r--r--sys/boot/efi/include/efidef.h2
-rw-r--r--sys/boot/efi/include/i386/efibind.h4
-rw-r--r--sys/dev/cxgbe/t4_sge.c3
-rwxr-xr-xsys/dev/ixl/i40e_adminq.c5
-rwxr-xr-xsys/dev/ixl/i40e_adminq_cmd.h26
-rwxr-xr-xsys/dev/ixl/i40e_common.c98
-rwxr-xr-xsys/dev/ixl/i40e_lan_hmc.c25
-rwxr-xr-xsys/dev/ixl/i40e_prototype.h7
-rwxr-xr-xsys/dev/ixl/i40e_type.h25
-rwxr-xr-xsys/dev/ixl/if_ixl.c271
-rw-r--r--sys/dev/ixl/if_ixlv.c84
-rw-r--r--sys/dev/ixl/ixl.h7
-rw-r--r--sys/dev/ixl/ixl_pf.h3
-rwxr-xr-xsys/dev/ixl/ixl_txrx.c9
-rw-r--r--sys/dev/ixl/ixlvc.c9
-rw-r--r--sys/dev/sfxge/common/efsys.h20
-rw-r--r--sys/dev/sfxge/common/efx.h44
-rw-r--r--sys/dev/sfxge/common/efx_ev.c26
-rw-r--r--sys/dev/sfxge/common/efx_filter.c27
-rw-r--r--sys/dev/sfxge/common/efx_impl.h14
-rw-r--r--sys/dev/sfxge/common/efx_mcdi.c31
-rw-r--r--sys/dev/sfxge/common/efx_mcdi.h3
-rw-r--r--sys/dev/sfxge/common/efx_mon.c16
-rw-r--r--sys/dev/sfxge/common/efx_nic.c9
-rw-r--r--sys/dev/sfxge/common/efx_phy.c13
-rw-r--r--sys/dev/sfxge/common/efx_regs_ef10.h136
-rw-r--r--sys/dev/sfxge/common/efx_regs_mcdi.h2389
-rw-r--r--sys/dev/sfxge/common/efx_tx.c5
-rw-r--r--sys/dev/sfxge/common/siena_mac.c1
-rw-r--r--sys/dev/sfxge/common/siena_mon.c10
-rw-r--r--sys/dev/sfxge/common/siena_nic.c42
-rw-r--r--sys/dev/sfxge/common/siena_nvram.c2
-rw-r--r--sys/dev/sfxge/common/siena_sram.c7
-rw-r--r--sys/dev/sfxge/sfxge_rx.c4
-rw-r--r--sys/dev/sfxge/sfxge_tx.c60
-rw-r--r--sys/dev/sfxge/sfxge_tx.h18
-rw-r--r--sys/kern/kern_ctf.c12
-rw-r--r--sys/kern/link_elf.c8
-rw-r--r--sys/net/if_var.h10
-rw-r--r--sys/net/if_vlan.c21
-rw-r--r--sys/netinet/igmp.c110
-rw-r--r--sys/netinet/igmp_var.h81
-rw-r--r--sys/netinet/in_var.h53
-rw-r--r--sys/netinet6/in6_var.h10
-rw-r--r--sys/netinet6/mld6.c99
-rw-r--r--sys/netinet6/mld6_var.h65
-rw-r--r--sys/powerpc/powermac/powermac_thermal.c28
-rw-r--r--sys/powerpc/ps3/ps3_syscons.c10
-rw-r--r--sys/x86/acpica/acpi_wakeup.c9
-rw-r--r--sys/x86/iommu/busdma_dmar.c32
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc4
-rw-r--r--usr.bin/mkimg/Makefile2
-rw-r--r--usr.bin/mkimg/mkimg.127
-rw-r--r--usr.bin/mkimg/mkimg.c59
-rw-r--r--usr.bin/mkimg/scheme.c17
-rw-r--r--usr.bin/netstat/Makefile2
-rw-r--r--usr.bin/netstat/bpf.c56
-rw-r--r--usr.bin/netstat/flowtable.c1
-rw-r--r--usr.bin/netstat/if.c319
-rw-r--r--usr.bin/netstat/inet.c995
-rw-r--r--usr.bin/netstat/inet6.c647
-rw-r--r--usr.bin/netstat/ipsec.c262
-rw-r--r--usr.bin/netstat/main.c100
-rw-r--r--usr.bin/netstat/mbuf.c106
-rw-r--r--usr.bin/netstat/mroute.c207
-rw-r--r--usr.bin/netstat/mroute6.c130
-rw-r--r--usr.bin/netstat/netgraph.c25
-rw-r--r--usr.bin/netstat/netisr.c190
-rw-r--r--usr.bin/netstat/netstat.116
-rw-r--r--usr.bin/netstat/netstat.h4
-rw-r--r--usr.bin/netstat/pfkey.c94
-rw-r--r--usr.bin/netstat/route.c320
-rw-r--r--usr.bin/netstat/sctp.c438
-rw-r--r--usr.bin/netstat/unix.c73
-rw-r--r--usr.sbin/Makefile2
-rw-r--r--usr.sbin/ifmcstat/Makefile5
-rw-r--r--usr.sbin/ifmcstat/ifmcstat.c30
-rw-r--r--usr.sbin/jls/jls.83
-rw-r--r--usr.sbin/jls/jls.c20
-rw-r--r--usr.sbin/pmccontrol/pmccontrol.c4
124 files changed, 6375 insertions, 2608 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 0c969ff..7fca582 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -93,6 +93,11 @@ OLD_FILES+=usr/lib/clang/3.5.1/lib/freebsd/libclang_rt.ubsan_cxx-x86_64.a
OLD_DIRS+=usr/lib/clang/3.5.1/lib/freebsd
OLD_DIRS+=usr/lib/clang/3.5.1/lib
OLD_DIRS+=usr/lib/clang/3.5.1
+# 20150222: Removed bcd(6) and ppt(6)
+OLD_FILES+=usr/bin/bcd
+OLD_FILES+=usr/bin/ppt
+OLD_FILES+=usr/share/man/man6/bcd.6.gz
+OLD_FILES+=usr/share/man/man6/ppt.6.gz
# 20150217: Removed remnants of ar(4) driver
OLD_FILES+=usr/include/sys/dev/ic/hd64570.h
# 20150212: /usr/games moving into /usr/bin
diff --git a/UPDATING b/UPDATING
index 5e144c4..f592cce 100644
--- a/UPDATING
+++ b/UPDATING
@@ -39,7 +39,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
but before r278950, the RNG was not seeded properly. Immediately
upgrade the kernel to r278950 or later and regenerate any keys (e.g.
ssh keys or openssl keys) that were generated w/ a kernel from that
- range. This does not effect programs that directly used /dev/random
+ range. This does not affect programs that directly used /dev/random
or /dev/urandom. All userland uses of arc4random(3) are affected.
20150210:
diff --git a/bin/pkill/tests/pgrep-j_test.sh b/bin/pkill/tests/pgrep-j_test.sh
index 4830ace..e24e5c2 100644
--- a/bin/pkill/tests/pgrep-j_test.sh
+++ b/bin/pkill/tests/pgrep-j_test.sh
@@ -4,7 +4,7 @@
jail_name_to_jid()
{
local check_name="$1"
- jls -j "$check_name" -s 2>/dev/null | tr ' ' '\n' | grep jid= | sed -e 's/.*=//g'
+ jls -j "$check_name" -s | tr ' ' '\n' | grep jid= | sed -e 's/.*=//g'
}
base=pgrep_j_test
@@ -38,6 +38,7 @@ for i in `seq 1 10`; do
esac
sleep 0.1
done
+sleep 0.5
pid1="$(pgrep -f -x -j "$jid" "$sleep $sleep_amount" | sort)"
pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_1_1.pid)" \
diff --git a/bin/pkill/tests/pkill-j_test.sh b/bin/pkill/tests/pkill-j_test.sh
index 5635df3..26e185f 100644
--- a/bin/pkill/tests/pkill-j_test.sh
+++ b/bin/pkill/tests/pkill-j_test.sh
@@ -4,7 +4,7 @@
jail_name_to_jid()
{
local check_name="$1"
- jls -j "$check_name" -s 2>/dev/null | tr ' ' '\n' | grep jid= | sed -e 's/.*=//g'
+ jls -j "$check_name" -s | tr ' ' '\n' | grep jid= | sed -e 's/.*=//g'
}
base=pkill_j_test
@@ -40,6 +40,7 @@ for i in `seq 1 10`; do
esac
sleep 0.1
done
+sleep 0.5
if pkill -f -j "$jid" $sleep && sleep 0.5 &&
! -f ${PWD}/${base}_1_1.pid &&
diff --git a/contrib/ipfilter/ip_fil.c b/contrib/ipfilter/ip_fil.c
index 9178bd3..03e4093 100644
--- a/contrib/ipfilter/ip_fil.c
+++ b/contrib/ipfilter/ip_fil.c
@@ -44,6 +44,9 @@ static int write_output __P((struct ifnet *, struct mbuf *,
# endif
#endif
+struct ifaddr {
+ struct sockaddr_storage ifa_addr;
+};
int
ipfattach(softc)
diff --git a/contrib/ipfilter/ipf.h b/contrib/ipfilter/ipf.h
index d4bd524..dfae008 100644
--- a/contrib/ipfilter/ipf.h
+++ b/contrib/ipfilter/ipf.h
@@ -43,9 +43,6 @@ struct file;
#include <sys/socket.h>
#include <net/if.h>
-#define _WANT_IFADDR
-#include <net/if_var.h>
-
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
diff --git a/contrib/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/contrib/llvm/lib/Transforms/Scalar/LoopRotation.cpp
index 9164be2..267cb99 100644
--- a/contrib/llvm/lib/Transforms/Scalar/LoopRotation.cpp
+++ b/contrib/llvm/lib/Transforms/Scalar/LoopRotation.cpp
@@ -535,6 +535,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
Loop *PredLoop = LI->getLoopFor(*PI);
if (!PredLoop || PredLoop->contains(Exit))
continue;
+ if (isa<IndirectBrInst>((*PI)->getTerminator()))
+ continue;
SplitLatchEdge |= L->getLoopLatch() == *PI;
BasicBlock *ExitSplit = SplitCriticalEdge(*PI, Exit, this);
ExitSplit->moveBefore(Exit);
diff --git a/contrib/llvm/patches/patch-08-llvm-r230058-indirectbrs-assert.diff b/contrib/llvm/patches/patch-08-llvm-r230058-indirectbrs-assert.diff
new file mode 100644
index 0000000..f3e0112
--- /dev/null
+++ b/contrib/llvm/patches/patch-08-llvm-r230058-indirectbrs-assert.diff
@@ -0,0 +1,55 @@
+Pull in r230058 from upstream llvm trunk (by Benjamin Kramer):
+
+ LoopRotate: When reconstructing loop simplify form don't split edges
+ from indirectbrs.
+
+ Yet another chapter in the endless story. While this looks like we
+ leave the loop in a non-canonical state this replicates the logic in
+ LoopSimplify so it doesn't diverge from the canonical form in any way.
+
+ PR21968
+
+This fixes a "Cannot split critical edge from IndirectBrInst" assertion
+failure when building the devel/radare2 port.
+
+Introduced here: https://svnweb.freebsd.org/changeset/base/279161
+
+Index: lib/Transforms/Scalar/LoopRotation.cpp
+===================================================================
+--- lib/Transforms/Scalar/LoopRotation.cpp
++++ lib/Transforms/Scalar/LoopRotation.cpp
+@@ -498,6 +498,8 @@ bool LoopRotate::rotateLoop(Loop *L, bool Simplifi
+ Loop *PredLoop = LI->getLoopFor(*PI);
+ if (!PredLoop || PredLoop->contains(Exit))
+ continue;
++ if (isa<IndirectBrInst>((*PI)->getTerminator()))
++ continue;
+ SplitLatchEdge |= L->getLoopLatch() == *PI;
+ BasicBlock *ExitSplit = SplitCriticalEdge(*PI, Exit, this);
+ ExitSplit->moveBefore(Exit);
+Index: test/Transforms/LoopRotate/crash.ll
+===================================================================
+--- test/Transforms/LoopRotate/crash.ll
++++ test/Transforms/LoopRotate/crash.ll
+@@ -153,3 +153,21 @@ entry:
+ "5": ; preds = %"3", %entry
+ ret void
+ }
++
++; PR21968
++define void @test8(i1 %C, i8* %P) #0 {
++entry:
++ br label %for.cond
++
++for.cond: ; preds = %for.inc, %entry
++ br i1 %C, label %l_bad, label %for.body
++
++for.body: ; preds = %for.cond
++ indirectbr i8* %P, [label %for.inc, label %l_bad]
++
++for.inc: ; preds = %for.body
++ br label %for.cond
++
++l_bad: ; preds = %for.body, %for.cond
++ ret void
++}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_nice.c b/contrib/netbsd-tests/lib/libc/gen/t_nice.c
index 10b8df7..f4a62e9 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_nice.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_nice.c
@@ -72,11 +72,6 @@ ATF_TC_BODY(nice_err, tc)
{
int i;
-#ifdef __FreeBSD__
- atf_tc_expect_fail("nice(incr) with incr < 0 fails with unprivileged "
- "users and sets errno == EPERM; see PR # 189821 for more details");
-#endif
-
/*
* The call should fail with EPERM if the
* supplied parameter is negative and the
@@ -98,11 +93,7 @@ ATF_TC_HEAD(nice_priority, tc)
ATF_TC_BODY(nice_priority, tc)
{
-#ifdef __FreeBSD__
- int i, pri, pri2, nic;
-#else
int i, pri, nic;
-#endif
pid_t pid;
int sta;
@@ -115,10 +106,8 @@ ATF_TC_BODY(nice_priority, tc)
pri = getpriority(PRIO_PROCESS, 0);
ATF_REQUIRE(errno == 0);
-#ifdef __NetBSD__
if (nic != pri)
atf_tc_fail("nice(3) and getpriority(2) conflict");
-#endif
/*
* Also verify that the nice(3) values
@@ -130,18 +119,10 @@ ATF_TC_BODY(nice_priority, tc)
if (pid == 0) {
errno = 0;
-#ifdef __FreeBSD__
pri = getpriority(PRIO_PROCESS, 0);
-#else
- pri2 = getpriority(PRIO_PROCESS, 0);
-#endif
ATF_REQUIRE(errno == 0);
-#ifdef __FreeBSD__
- if (pri != pri2)
-#else
if (nic != pri)
-#endif
_exit(EXIT_FAILURE);
_exit(EXIT_SUCCESS);
@@ -180,11 +161,7 @@ ATF_TC_HEAD(nice_thread, tc)
ATF_TC_BODY(nice_thread, tc)
{
pthread_t tid[5];
-#ifdef __FreeBSD__
- int pri, rv, val;
-#else
int rv, val;
-#endif
size_t i;
/*
@@ -196,12 +173,7 @@ ATF_TC_BODY(nice_thread, tc)
val = nice(i);
ATF_REQUIRE(val != -1);
-#ifdef __FreeBSD__
- pri = getpriority(PRIO_PROCESS, 0);
- rv = pthread_create(&tid[i], NULL, threadfunc, &pri);
-#else
rv = pthread_create(&tid[i], NULL, threadfunc, &val);
-#endif
ATF_REQUIRE(rv == 0);
rv = pthread_join(tid[i], NULL);
diff --git a/etc/netstart b/etc/netstart
index 44b8ab7..4adcae2 100755
--- a/etc/netstart
+++ b/etc/netstart
@@ -57,7 +57,6 @@ _start=quietstart
/etc/rc.d/routing ${_start}
/etc/rc.d/mroute6d ${_start}
/etc/rc.d/route6d ${_start}
-/etc/rc.d/mrouted ${_start}
/etc/rc.d/routed ${_start}
/etc/rc.d/rtsold ${_start}
/etc/rc.d/nisdomain ${_start}
diff --git a/games/Makefile b/games/Makefile
index a3bb296..4a3da52 100644
--- a/games/Makefile
+++ b/games/Makefile
@@ -3,7 +3,6 @@
.include <src.opts.mk>
SUBDIR= \
- bcd \
caesar \
factor \
fortune \
@@ -11,7 +10,6 @@ SUBDIR= \
morse \
number \
pom \
- ppt \
primes \
random \
${_tests}
diff --git a/games/bcd/Makefile b/games/bcd/Makefile
deleted file mode 100644
index 1e0bbfc..0000000
--- a/games/bcd/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
-
-PROG= bcd
-MAN= bcd.6
-MLINKS= bcd.6 ppt.6
-
-.include <bsd.prog.mk>
-
diff --git a/games/bcd/bcd.6 b/games/bcd/bcd.6
deleted file mode 100644
index e9343fe..0000000
--- a/games/bcd/bcd.6
+++ /dev/null
@@ -1,52 +0,0 @@
-.\" Copyright (c) 1988, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
-.\"
-.\" @(#)bcd.6 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
-.\"
-.Dd December 7, 2000
-.Dt BCD 6
-.Os
-.Sh NAME
-.Nm bcd ,
-.Nm ppt
-.Nd "reformat input as punch cards or paper tape"
-.Sh SYNOPSIS
-.Nm
-.Op Ar string ...
-.Nm ppt
-.Op Ar string ...
-.Sh DESCRIPTION
-The commands
-.Nm
-and
-.Nm ppt
-read the given input and reformat it in the form of punched cards or
-paper tape.
-Acceptable input are command line arguments or the standard input.
-.Sh SEE ALSO
-.Xr morse 6
diff --git a/games/bcd/bcd.c b/games/bcd/bcd.c
deleted file mode 100644
index 04ccccc..0000000
--- a/games/bcd/bcd.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Steve Hayman of the Indiana University Computer Science Dept.
- *
- * 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * bcd --
- *
- * Read one line of standard input and produce something that looks like a
- * punch card. An attempt to reimplement /usr/games/bcd. All I looked at
- * was the man page.
- *
- * I couldn't find a BCD table handy so I wrote a shell script to deduce what
- * the patterns were that the old bcd was using for each possible 8-bit
- * character. These are the results -- the low order 12 bits represent the
- * holes. (A 1 bit is a hole.) These may be wrong, but they match the old
- * program!
- *
- * Steve Hayman
- * sahayman@iuvax.cs.indiana.edu
- * 1989 11 30
- *
- *
- * I found an error in the table. The same error is found in the SunOS 4.1.1
- * version of bcd. It has apparently been around a long time. The error caused
- * 'Q' and 'R' to have the same punch code. I only noticed the error due to
- * someone pointing it out to me when the program was used to print a cover
- * for an APA! The table was wrong in 4 places. The other error was masked
- * by the fact that the input is converted to upper case before lookup.
- *
- * Dyane Bruce
- * db@diana.ocunix.on.ca
- * Nov 5, 1993
- */
-
-#include <sys/types.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static u_short holes[256] = {
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x206, 0x20a, 0x042, 0x442, 0x222, 0x800, 0x406,
- 0x812, 0x412, 0x422, 0xa00, 0x242, 0x400, 0x842, 0x300,
- 0x200, 0x100, 0x080, 0x040, 0x020, 0x010, 0x008, 0x004,
- 0x002, 0x001, 0x012, 0x40a, 0x80a, 0x212, 0x00a, 0x006,
- 0x022, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804,
- 0x802, 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408,
- 0x404, 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208,
- 0x204, 0x202, 0x201, 0x082, 0x822, 0x600, 0x282, 0x30f,
- 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802,
- 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404,
- 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204,
- 0x202, 0x201, 0x082, 0x806, 0x822, 0x600, 0x282, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x206, 0x20a, 0x042, 0x442, 0x222, 0x800, 0x406, 0x812,
- 0x412, 0x422, 0xa00, 0x242, 0x400, 0x842, 0x300, 0x200,
- 0x100, 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002,
- 0x001, 0x012, 0x40a, 0x80a, 0x212, 0x00a, 0x006, 0x022,
- 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802,
- 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404,
- 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204,
- 0x202, 0x201, 0x082, 0x806, 0x822, 0x600, 0x282, 0x30f,
- 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, 0x802,
- 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, 0x404,
- 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, 0x204,
- 0x202, 0x201, 0x082, 0x806, 0x822, 0x600, 0x282, 0x0
-};
-
-static void printcard(char *);
-
-/*
- * i'th bit of w.
- */
-#define bit(w,i) ((w)&(1<<(i)))
-
-int
-main(int argc, char **argv)
-{
- char cardline[80];
-
- /*
- * The original bcd prompts with a "%" when reading from stdin,
- * but this seems kind of silly. So this one doesn't.
- */
-
- if (argc > 1) {
- while (--argc)
- printcard(*++argv);
- } else
- while (fgets(cardline, sizeof(cardline), stdin))
- printcard(cardline);
- exit(0);
-}
-
-#define COLUMNS 48
-
-static void
-printcard(char *str)
-{
- static char rowchars[] = " 123456789";
- int i, row;
- char *p;
-
- /* ruthlessly remove newlines and truncate at 48 characters. */
- if ((p = strchr(str, '\n')))
- *p = '\0';
-
- if (strlen(str) > COLUMNS)
- str[COLUMNS] = '\0';
-
- /* make string upper case. */
- for (p = str; *p; ++p)
- if (isascii(*p) && islower(*p))
- *p = toupper(*p);
-
- /* top of card */
- putchar(' ');
- for (i = 1; i <= COLUMNS; ++i)
- putchar('_');
- putchar('\n');
-
- /*
- * line of text. Leave a blank if the character doesn't have
- * a hole pattern.
- */
- p = str;
- putchar('/');
- for (i = 1; *p; i++, p++)
- if (holes[(unsigned char)*p])
- putchar(*p);
- else
- putchar(' ');
- while (i++ <= COLUMNS)
- putchar(' ');
- putchar('|');
- putchar('\n');
-
- /*
- * 12 rows of potential holes; output a ']', which looks kind of
- * like a hole, if the appropriate bit is set in the holes[] table.
- * The original bcd output a '[', a backspace, five control A's,
- * and then a ']'. This seems a little excessive.
- */
- for (row = 0; row <= 11; ++row) {
- putchar('|');
- for (i = 0, p = str; *p; i++, p++) {
- if (bit(holes[(unsigned char)*p], 11 - row))
- putchar(']');
- else
- putchar(rowchars[row]);
- }
- while (i++ < COLUMNS)
- putchar(rowchars[row]);
- putchar('|');
- putchar('\n');
- }
-
- /* bottom of card */
- putchar('|');
- for (i = 1; i <= COLUMNS; i++)
- putchar('_');
- putchar('|');
- putchar('\n');
-}
diff --git a/games/ppt/Makefile b/games/ppt/Makefile
deleted file mode 100644
index 4a3629f..0000000
--- a/games/ppt/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $FreeBSD$
-
-PROG= ppt
-MAN=
-
-.include <bsd.prog.mk>
-
diff --git a/games/ppt/ppt.c b/games/ppt/ppt.c
deleted file mode 100644
index a032e13..0000000
--- a/games/ppt/ppt.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)ppt.c 8.1 (Berkeley) 5/31/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-static void putppt(int);
-
-int
-main(int argc, char **argv)
-{
- int c;
- char *p;
-
- (void) puts("___________");
- if (argc > 1)
- while ((p = *++argv))
- for (; *p; ++p)
- putppt((int)*p);
- else while ((c = getchar()) != EOF)
- putppt(c);
- (void) puts("___________");
- exit(0);
-}
-
-static void
-putppt(int c)
-{
- int i;
-
- (void) putchar('|');
- for (i = 7; i >= 0; i--) {
- if (i == 2)
- (void) putchar('.'); /* feed hole */
- if ((c&(1<<i)) != 0)
- (void) putchar('o');
- else
- (void) putchar(' ');
- }
- (void) putchar('|');
- (void) putchar('\n');
-}
diff --git a/lib/libc/db/man/dbm.3 b/lib/libc/db/man/dbm.3
index fabce8a..eedf804 100644
--- a/lib/libc/db/man/dbm.3
+++ b/lib/libc/db/man/dbm.3
@@ -15,7 +15,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 16, 2006
+.Dd February 19, 2015
.Dt DBM 3
.Os
.Sh NAME
@@ -174,9 +174,7 @@ deletes the entry for
The
.Fn dbm_delete
function
-normally returns zero but returns 1 if there was no entry with
-.Fa key
-in the database or returns -1 and sets
+normally returns zero or returns -1 and sets
.Va errno
if there were any errors.
.Pp
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 4ba24ae..1f4d7e9 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -1173,8 +1173,10 @@ nis_group(void *retval, void *mdata, va_list ap)
* terminator, alignment padding, and one (char *)
* pointer for the member list terminator.
*/
- if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *))
+ if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *)) {
+ free(result);
goto erange;
+ }
memcpy(buffer, result, resultlen);
buffer[resultlen] = '\0';
free(result);
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 6cd7eaf..0cb8ed2 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1392,8 +1392,10 @@ nis_passwd(void *retval, void *mdata, va_list ap)
continue;
}
}
- if (resultlen >= bufsize)
+ if (resultlen >= bufsize) {
+ free(result);
goto erange;
+ }
memcpy(buffer, result, resultlen);
buffer[resultlen] = '\0';
free(result);
diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3
index 9c39b78..3bad5f7 100644
--- a/lib/libc/gen/nice.3
+++ b/lib/libc/gen/nice.3
@@ -28,7 +28,7 @@
.\" @(#)nice.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd February 22, 2015
.Dt NICE 3
.Os
.Sh NAME
@@ -57,11 +57,34 @@ Only the super-user may lower priorities.
.Pp
Children inherit the priority of their parent processes via
.Xr fork 2 .
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn nice
+returns the new nice value minus
+.Dv NZERO .
+Otherwise, \-1 is returned, the process' nice value is not changed, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn nice
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The
+.Fa incr
+argument is negative and the caller does not have appropriate privileges.
+.El
.Sh SEE ALSO
.Xr nice 1 ,
.Xr fork 2 ,
.Xr setpriority 2 ,
.Xr renice 8
+.Sh STANDARDS
+The
+.Fn nice
+function conforms to
+.St -xpg4.2 .
.Sh HISTORY
A
.Fn nice
diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c
index e8375e8..58cde98 100644
--- a/lib/libc/gen/nice.c
+++ b/lib/libc/gen/nice.c
@@ -43,14 +43,18 @@ __FBSDID("$FreeBSD$");
* Backwards compatible nice.
*/
int
-nice(incr)
- int incr;
+nice(int incr)
{
int prio;
errno = 0;
prio = getpriority(PRIO_PROCESS, 0);
if (prio == -1 && errno)
- return (-1);
- return (setpriority(PRIO_PROCESS, 0, prio + incr));
+ return -1;
+ if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) {
+ if (errno == EACCES)
+ errno = EPERM;
+ return -1;
+ }
+ return getpriority(PRIO_PROCESS, 0);
}
diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c
index 3966fd0..ffa20fd 100644
--- a/lib/libc/gen/setmode.c
+++ b/lib/libc/gen/setmode.c
@@ -186,10 +186,10 @@ setmode(const char *p)
* as best we can.
*/
sigfillset(&sigset);
- (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+ (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset);
(void)umask(mask = umask(0));
mask = ~mask;
- (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL);
+ (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL);
setlen = SET_LEN + 2;
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c
index 589bb9d..436370d 100644
--- a/lib/libc/regex/engine.c
+++ b/lib/libc/regex/engine.c
@@ -157,7 +157,7 @@ matcher(struct re_guts *g,
int i;
struct match mv;
struct match *m = &mv;
- const char *dp;
+ const char *dp = NULL;
const sopno gf = g->firststate+1; /* +1 for OEND */
const sopno gl = g->laststate;
const char *start;
@@ -244,7 +244,7 @@ matcher(struct re_guts *g,
ZAPSTATE(&m->mbs);
/* Adjust start according to moffset, to speed things up */
- if (g->moffset > -1)
+ if (dp != NULL && g->moffset > -1)
start = ((dp - g->moffset) < start) ? start : dp - g->moffset;
SP("mloop", m->st, *start);
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index ae92f6a..2da5066 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -1422,8 +1422,8 @@ static void
findmust(struct parse *p, struct re_guts *g)
{
sop *scan;
- sop *start;
- sop *newstart;
+ sop *start = NULL;
+ sop *newstart = NULL;
sopno newlen;
sop s;
char *cp;
diff --git a/lib/msun/src/e_j0.c b/lib/msun/src/e_j0.c
index a1ac7c7..8fd2a9b 100644
--- a/lib/msun/src/e_j0.c
+++ b/lib/msun/src/e_j0.c
@@ -278,7 +278,7 @@ static const double pS2[5] = {
if(ix>=0x40200000) {p = pR8; q= pS8;}
else if(ix>=0x40122E8B){p = pR5; q= pS5;}
else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
- else if(ix>=0x40000000){p = pR2; q= pS2;}
+ else {p = pR2; q= pS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
diff --git a/lib/msun/src/e_j0f.c b/lib/msun/src/e_j0f.c
index f7c463b..75563ef 100644
--- a/lib/msun/src/e_j0f.c
+++ b/lib/msun/src/e_j0f.c
@@ -234,7 +234,7 @@ static const float pS2[5] = {
if(ix>=0x41000000) {p = pR8; q= pS8;}
else if(ix>=0x40f71c58){p = pR5; q= pS5;}
else if(ix>=0x4036db68){p = pR3; q= pS3;}
- else if(ix>=0x40000000){p = pR2; q= pS2;}
+ else {p = pR2; q= pS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
diff --git a/lib/msun/src/e_j1.c b/lib/msun/src/e_j1.c
index 63800ad..6d07b61 100644
--- a/lib/msun/src/e_j1.c
+++ b/lib/msun/src/e_j1.c
@@ -272,7 +272,7 @@ static const double ps2[5] = {
if(ix>=0x40200000) {p = pr8; q= ps8;}
else if(ix>=0x40122E8B){p = pr5; q= ps5;}
else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
- else if(ix>=0x40000000){p = pr2; q= ps2;}
+ else {p = pr2; q= ps2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
diff --git a/lib/msun/src/e_j1f.c b/lib/msun/src/e_j1f.c
index 88e2d83..3492edd 100644
--- a/lib/msun/src/e_j1f.c
+++ b/lib/msun/src/e_j1f.c
@@ -229,7 +229,7 @@ static const float ps2[5] = {
if(ix>=0x41000000) {p = pr8; q= ps8;}
else if(ix>=0x40f71c58){p = pr5; q= ps5;}
else if(ix>=0x4036db68){p = pr3; q= ps3;}
- else if(ix>=0x40000000){p = pr2; q= ps2;}
+ else {p = pr2; q= ps2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
diff --git a/release/doc/en_US.ISO8859-1/relnotes/article.xml b/release/doc/en_US.ISO8859-1/relnotes/article.xml
index 4fe344c..5bcb225 100644
--- a/release/doc/en_US.ISO8859-1/relnotes/article.xml
+++ b/release/doc/en_US.ISO8859-1/relnotes/article.xml
@@ -22,7 +22,7 @@
<pubdate>$FreeBSD$</pubdate>
- <!-- Last rev: 277458 -->
+ <!-- Last rev: 278934 -->
<copyright>
<year>2015</year>
@@ -302,6 +302,13 @@
<para revision="277166" arch="powerpc">The &man.ptrace.2; system
call has been updated include support for Altivec registers on
&os;/&arch.powerpc;.</para>
+
+ <para revision="278320">A new device control utility,
+ &man.devctl.8; has been added, which allows making
+ administrative changes to individual devices, such as
+ attaching and detaching drivers, and enabling and disabling
+ devices. The &man.devctl.8; utility uses the new
+ &man.devctl.3; library.</para>
</sect2>
<sect2 xml:id="userland-contrib">
@@ -375,6 +382,12 @@
<para revision="277270"><application>OpenSSL</application> has
been updated to version 1.0.1l.</para>
+
+ <para revision="278433">The &man.xz.1; utility has been udpated
+ to version 5.2.0.</para>
+
+ <para revision="278433">The &man.xz.1; utility has been updated
+ to support multi-threaded compression.</para>
</sect2>
<sect2 xml:id="userland-installer">
@@ -460,6 +473,16 @@
<para revision="274987">The &man.gpio.3; library has been added,
providing a wrapper around the &man.gpio.4; kernel
interface.</para>
+
+ <para revision="277610">The <literal>futimens()</literal> and
+ <literal>utimensat()</literal> system calls have been
+ added. See &man.utimensat.2; for more information.</para>
+
+ <para revision="278934">The &man.elf.3; compile-time dependency
+ has been removed from <filename>dtri.o</filename>, which
+ allows adding <application>DTrace</application> probes to
+ userland applications and libraries without also linking
+ against &man.elf.3;.</para>
</sect2>
<sect2 xml:id="userland-abi">
@@ -515,12 +538,32 @@
at the &man.loader.8; prompt during boot, or add
<literal>kern.vty=vt</literal> to &man.loader.conf.5; and
reboot the system.</para>
+
+ <para revision="277904">The &man.config.8; utility has been
+ updated to allow using a non-standard <filename
+ class="directory">src/</filename> tree, specified as an
+ argument to the <literal>-s</literal> flag.</para>
+
+ <para revision="277990" arch="powerpc64">The
+ &os;/&arch.powerpc64; kernel now builds as
+ a position-independent executable, allowing the kernel to be
+ loaded into and run from any physical or virtual
+ address.</para>
+
+ <important>
+ <para>This change requires an update to &man.loader.8;.
+ The userland and kernel must be updated before rebooting the
+ system.</para>
+ </important>
</sect2>
<sect2 xml:id="kernel-sysctl">
<title>System Tuning and Controls</title>
- <para>&nbsp;</para>
+ <para revision="275140" contrib="sponsor" sponsor="&ff;">The
+ &man.hwpmc.4; default and maximum callchain depths have been
+ increased. The default has been increased from 16 to 32, and
+ the maximum increased from 32 to 128.</para>
</sect2>
</sect1>
@@ -761,6 +804,18 @@
<para>This section covers changes and additions to file systems
and other storage subsystems, both local and networked.</para>
+ <sect2 xml:id="storage-general">
+ <title>General Storage</title>
+ <para revision="278037" contrib="sponsor" sponsor="&ix;">The
+ &man.ctl.4; <acronym>LUN</acronym> mapping has been rewritten,
+ replacing <acronym>iSCSI</acronym>-specific mapping mechanisms
+ with a new mechanism that works for any port.</para>
+
+ <para revision="278354" contrib="sponsor" sponsor="&ix;">The
+ &man.ctld.8; utility has been updated to allow controlling
+ non-<acronym>iSCSI</acronym> &man.ctl.4; ports.</para>
+ </sect2>
+
<sect2 xml:id="storage-net">
<title>Networked Storage</title>
@@ -962,6 +1017,11 @@
Release Engineering build tools have been updated to include
support for producing virtual machine disk images for various
cloud hosting providers.</para>
+
+ <para revision="278926">The Release Engineering build tools have
+ been updated to use multi-threaded &man.xz.1;. By default,
+ the number of &man.xz.1; threads is set to the number of cores
+ available.</para>
</sect2>
</sect1>
</article>
diff --git a/release/release.conf.sample b/release/release.conf.sample
index f6cfadc..aecfc34 100644
--- a/release/release.conf.sample
+++ b/release/release.conf.sample
@@ -53,6 +53,9 @@ PORTBRANCH="ports/head@rHEAD"
#WITH_DVD=
#WITH_COMPRESSED_IMAGES=
+## Set to '1' to disable multi-threaded xz(1) compression.
+#XZ_THREADS=0
+
## Set when building embedded images.
#EMBEDDEDBUILD=
diff --git a/release/release.sh b/release/release.sh
index 01a1727..6511ec1 100755
--- a/release/release.sh
+++ b/release/release.sh
@@ -93,6 +93,7 @@ WITH_COMPRESSED_IMAGES=
# the release.
WITH_VMIMAGES=
WITH_COMPRESSED_VMIMAGES=
+XZ_THREADS=0
# Set to non-empty value to build virtual machine images for various
# cloud providers as part of the release.
@@ -179,7 +180,7 @@ RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
- WITH_CLOUDWARE=${WITH_CLOUDWARE}"
+ WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
# Force src checkout if configured
FORCE_SRC_KEY=
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 8d83f62..d9c04b9 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -573,7 +573,9 @@ MLINKS+=cdce.4 if_cdce.4
MLINKS+=crypto.4 cryptodev.4
MLINKS+=cue.4 if_cue.4
MLINKS+=cxgb.4 if_cxgb.4
-MLINKS+=cxgbe.4 if_cxgbe.4
+MLINKS+=cxgbe.4 if_cxgbe.4 \
+ cxgbe.4 cxl.4 \
+ cxgbe.4 if_cxl.4
MLINKS+=dc.4 if_dc.4
MLINKS+=de.4 if_de.4
MLINKS+=disc.4 if_disc.4
diff --git a/share/man/man4/man4.arm/devcfg.4 b/share/man/man4/man4.arm/devcfg.4
index 83c4168..f330446 100644
--- a/share/man/man4/man4.arm/devcfg.4
+++ b/share/man/man4/man4.arm/devcfg.4
@@ -92,4 +92,4 @@ driver.
.Sh SEE ALSO
Zynq-7000 SoC Technical Reference Manual (Xilinx doc UG585)
.Sh AUTHORS
-Thomas Skibo
+.An Thomas Skibo
diff --git a/share/man/man4/man4.i386/apm.4 b/share/man/man4/man4.i386/apm.4
index 6d7b524..b5ad928 100644
--- a/share/man/man4/man4.i386/apm.4
+++ b/share/man/man4/man4.i386/apm.4
@@ -121,7 +121,7 @@ polls APM events and handles the following events.
.Xr apm 8 ,
.Xr zzz 8
.Sh AUTHORS
-Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
+.An Tatsumi Hosokawa Aq Mt hosokawa@jp.FreeBSD.org
.Sh BUGS
WARNING!
Many, if not most, of the implementations of APM-bios in laptops
diff --git a/share/man/man4/man4.powerpc/Makefile b/share/man/man4/man4.powerpc/Makefile
index 09d8b70..2b5ec8e 100644
--- a/share/man/man4/man4.powerpc/Makefile
+++ b/share/man/man4/man4.powerpc/Makefile
@@ -6,6 +6,7 @@ MAN= adb.4 \
ams.4 \
bm.4 \
cuda.4 \
+ llan.4 \
pmu.4 \
powermac_nvram.4 \
smu.4 \
diff --git a/share/man/man4/man4.powerpc/llan.4 b/share/man/man4/man4.powerpc/llan.4
new file mode 100644
index 0000000..b9bf49a
--- /dev/null
+++ b/share/man/man4/man4.powerpc/llan.4
@@ -0,0 +1,61 @@
+.\"-
+.\" Copyright (c) 2015 Nathan Whitehorn <nwhitehorn@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd February 19, 2015
+.Dt LLAN 4
+.Os
+.Sh NAME
+.Nm llan
+.Nd POWER Logical Lan
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following lines in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device llan"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the inter-partition logical LAN controller
+provided by PAPR-compliant POWER hypervisors (such as PowerVM and PowerKVM).
+On some firmwares, advanced offload features are supported by the hypervisor,
+but these are not currently supported by the driver.
+.Sh SEE ALSO
+.Xr vtnet 4 ,
+.Xr ifconfig 8
+.Sh HISTORY
+The
+.Nm
+device driver appeared in
+.Fx 10.0.
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Nathan Whitehorn Aq Mt nwhitehorn@FreeBSD.org .
diff --git a/share/man/man4/man4.powerpc/tsec.4 b/share/man/man4/man4.powerpc/tsec.4
index 84db70e..861e866 100644
--- a/share/man/man4/man4.powerpc/tsec.4
+++ b/share/man/man4/man4.powerpc/tsec.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 22, 2009
+.Dd February 20, 2015
.Dt TSEC 4
.Os
.Sh NAME
@@ -91,18 +91,23 @@ The
driver supports interrupts coalescing (IC) so that raising a transmit/receive
frame interrupt is delayed, if possible, until a threshold-defined period of
time has elapsed, or a threshold-defined frame counter has been reached
-(whichever occurs first). The following sysctls regulate this behaviour:
+(whichever occurs first).
+The following sysctls regulate this behaviour:
.Bl -tag -width indent
.It Va dev.tsec.X.int_coal.rx_time
.It Va dev.tsec.X.int_coal.rx_count
.It Va dev.tsec.X.int_coal.tx_time
.It Va dev.tsec.X.int_coal.tx_count
.Pp
-Value of 0 for either time or count disables IC on the given path. Time value
+Value of 0 for either time or count disables IC on the given path.
+Time value
1-65535 corresponds to a real time period and is expressed in units equivalent
-to 64 ticks of the TSEC clock. Count 1-255 represents the number of frames
-(note that value of 1 is equivalent to IC disabled). User provided values
-larger than supported will be trimmed to the maximum supported. More details
+to 64 ticks of the TSEC clock.
+Count 1-255 represents the number of frames
+(note that value of 1 is equivalent to IC disabled).
+User provided values
+larger than supported will be trimmed to the maximum supported.
+More details
are available in the reference manual of the device.
.El
.Sh HARDWARE
@@ -144,9 +149,9 @@ device driver first appeared in
The base version of
.Nm
device driver was written by
-.An Piotr Kruszynski.
+.An Piotr Kruszynski .
It has been extended with polling and interrupt coalescing support by
-.An Rafal Jaworowski.
+.An Rafal Jaworowski .
It has been further enhanced with multicast, h/w checksum calculation and vlan
support by
.An Piotr Ziecik .
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 5c4803f..86ba910 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 11, 2014
+.Dd February 20, 2015
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -2806,16 +2806,8 @@ these are the flags to pass to the routing daemon.
.Pq Vt str
The IPv6 equivalent of
.Va routed_flags .
-.It Va mrouted_enable
-.Pq Vt bool
-If set to
-.Dq Li YES ,
-run the multicast routing daemon,
-.Xr mrouted 8 .
.It Va mroute6d_enable
.Pq Vt bool
-The IPv6 equivalent of
-.Va mrouted_enable .
If set to
.Dq Li YES ,
run the IPv6 multicast routing daemon.
@@ -2829,19 +2821,8 @@ and
may be installed from the
.Fx
Ports Collection.
-.It Va mrouted_flags
-.Pq Vt str
-If
-.Va mrouted_enable
-is set to
-.Dq Li YES ,
-these are the flags to pass to the
-.Xr mrouted 8
-daemon.
.It Va mroute6d_flags
.Pq Vt str
-The IPv6 equivalent of
-.Va mrouted_flags .
If
.Va mroute6d_enable
is set to
@@ -4530,7 +4511,6 @@ ruleset to load for
.Xr mixer 8 ,
.Xr mountd 8 ,
.Xr moused 8 ,
-.Xr mrouted 8 ,
.Xr newfs 8 ,
.Xr newsyslog 8 ,
.Xr nfsd 8 ,
diff --git a/share/man/man7/release.7 b/share/man/man7/release.7
index ba7687e..a213813 100644
--- a/share/man/man7/release.7
+++ b/share/man/man7/release.7
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 28, 2015
+.Dd February 20, 2015
.Dt RELEASE 7
.Os
.Sh NAME
@@ -256,6 +256,15 @@ Set to a non-empty value to compress the release images with
The original
.Pq uncompressed
images are not removed.
+.It Va XZ_THREADS Pq Vt int
+Set to the number of threads
+.Xr xz 1
+should use when compressing images.
+By default,
+.Va XZ_THREADS
+is set to
+.Va 0 ,
+which uses all available cores on the system.
.It Va VCSCMD
The command run to obtain the source trees.
Defaults to
diff --git a/share/man/man9/microuptime.9 b/share/man/man9/microuptime.9
index 048143d..2ff5e9b 100644
--- a/share/man/man9/microuptime.9
+++ b/share/man/man9/microuptime.9
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 25, 2013
+.Dd February 21, 2015
.Dt MICROUPTIME 9
.Os
.Sh NAME
@@ -112,6 +112,7 @@ functions is to enforce the user's preference for timer accuracy versus
execution time.
.Sh SEE ALSO
.Xr bintime 9 ,
+.Xr get_cyclecount 9 ,
.Xr getbintime 9 ,
.Xr getmicrotime 9 ,
.Xr getnanotime 9 ,
diff --git a/share/misc/committers-doc.dot b/share/misc/committers-doc.dot
index 42ab60b..5b169d8 100644
--- a/share/misc/committers-doc.dot
+++ b/share/misc/committers-doc.dot
@@ -53,6 +53,7 @@ node [color=lightblue2, style=filled, bgcolor=black];
ale [label="Alex Dupre\nale@FreeBSD.org\n2003/12/22"]
allanjude [label="Allan Jude\nallanjude@FreeBSD.org\n2014/05/17"]
bcr [label="Benedict Reuschling\nbcr@FreeBSD.org\n2009/12/24"]
+bhd [label="Björn Heidotting\nbhd@FreeBSD.org\n2014/10/14"]
blackend [label="Marc Fonvieille\nblackend@FreeBSD.org\n2002/06/16"]
brd [label="Brad Davis\nbrd@FreeBSD.org\n2005/06/01"]
brueffer [label="Christian Brueffer\nbrueffer@FreeBSD.org\n2003/01/13"]
@@ -102,6 +103,7 @@ bcr -> dru
bcr -> crees
bcr -> jgh
bcr -> allanjude
+bcr -> bhd
blackend -> ale
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
index 3372b61..07fcbee 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
@@ -89,27 +89,39 @@ struct bcm_mbox_softc {
#define mbox_write_4(sc, reg, val) \
bus_space_write_4((sc)->bst, (sc)->bsh, reg, val)
+static int
+bcm_mbox_read_msg(struct bcm_mbox_softc *sc, int *ochan)
+{
+ uint32_t data;
+ uint32_t msg;
+ int chan;
+
+ msg = mbox_read_4(sc, REG_READ);
+ dprintf("bcm_mbox_intr: raw data %08x\n", msg);
+ chan = MBOX_CHAN(msg);
+ data = MBOX_DATA(msg);
+ if (sc->msg[chan]) {
+ printf("bcm_mbox_intr: channel %d oveflow\n", chan);
+ return (1);
+ }
+ dprintf("bcm_mbox_intr: chan %d, data %08x\n", chan, data);
+ sc->msg[chan] = msg;
+
+ if (ochan != NULL)
+ *ochan = chan;
+
+ return (0);
+}
+
static void
bcm_mbox_intr(void *arg)
{
struct bcm_mbox_softc *sc = arg;
int chan;
- uint32_t data;
- uint32_t msg;
- while (!(mbox_read_4(sc, REG_STATUS) & STATUS_EMPTY)) {
- msg = mbox_read_4(sc, REG_READ);
- dprintf("bcm_mbox_intr: raw data %08x\n", msg);
- chan = MBOX_CHAN(msg);
- data = MBOX_DATA(msg);
- if (sc->msg[chan]) {
- printf("bcm_mbox_intr: channel %d oveflow\n", chan);
- continue;
- }
- dprintf("bcm_mbox_intr: chan %d, data %08x\n", chan, data);
- sc->msg[chan] = msg;
- sema_post(&sc->sema[chan]);
- }
+ while (!(mbox_read_4(sc, REG_STATUS) & STATUS_EMPTY))
+ if (bcm_mbox_read_msg(sc, &chan) == 0)
+ sema_post(&sc->sema[chan]);
}
static int
@@ -201,14 +213,30 @@ static int
bcm_mbox_read(device_t dev, int chan, uint32_t *data)
{
struct bcm_mbox_softc *sc = device_get_softc(dev);
+ int err, read_chan;
dprintf("bcm_mbox_read: chan %d\n", chan);
+
+ err = 0;
MBOX_LOCK(sc);
- while (sema_trywait(&sc->sema[chan]) == 0) {
- /* do not unlock sc while waiting for the mbox */
- if (sema_timedwait(&sc->sema[chan], 10*hz) == 0)
- break;
- printf("timeout sema for chan %d\n", chan);
+ if (!cold) {
+ while (sema_trywait(&sc->sema[chan]) == 0) {
+ /* do not unlock sc while waiting for the mbox */
+ if (sema_timedwait(&sc->sema[chan], 10*hz) == 0)
+ break;
+ printf("timeout sema for chan %d\n", chan);
+ }
+ } else {
+ do {
+ /* Wait for a message */
+ while ((mbox_read_4(sc, REG_STATUS) & STATUS_EMPTY))
+ ;
+ /* Read the message */
+ if (bcm_mbox_read_msg(sc, &read_chan) != 0) {
+ err = EINVAL;
+ goto out;
+ }
+ } while (read_chan != chan);
}
/*
* get data from intr handler, the same channel is never coming
@@ -216,10 +244,11 @@ bcm_mbox_read(device_t dev, int chan, uint32_t *data)
*/
*data = MBOX_DATA(sc->msg[chan]);
sc->msg[chan] = 0;
+out:
MBOX_UNLOCK(sc);
dprintf("bcm_mbox_read: chan %d, data %08x\n", chan, *data);
- return (0);
+ return (err);
}
static device_method_t bcm_mbox_methods[] = {
diff --git a/sys/arm/include/atomic.h b/sys/arm/include/atomic.h
index 5857f5d..57fdf71 100644
--- a/sys/arm/include/atomic.h
+++ b/sys/arm/include/atomic.h
@@ -582,8 +582,8 @@ atomic_load_64(volatile uint64_t *p)
/*
* The only way to atomically load 64 bits is with LDREXD which puts the
- * exclusive monitor into the open state, so reset it with CLREX because
- * we don't actually need to store anything.
+ * exclusive monitor into the exclusive state, so reset it to open state
+ * with CLREX because we don't actually need to store anything.
*/
__asm __volatile(
"1: \n"
diff --git a/sys/boot/efi/include/amd64/efibind.h b/sys/boot/efi/include/amd64/efibind.h
index 1905596..3d70b58a 100644
--- a/sys/boot/efi/include/amd64/efibind.h
+++ b/sys/boot/efi/include/amd64/efibind.h
@@ -85,6 +85,9 @@ Revision History
// Basic EFI types of various widths
//
+#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
+#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
+
typedef uint64_t UINT64;
typedef int64_t INT64;
@@ -98,6 +101,7 @@ typedef int16_t INT16;
typedef uint8_t UINT8;
typedef int8_t INT8;
+#endif
#undef VOID
#define VOID void
diff --git a/sys/boot/efi/include/efidef.h b/sys/boot/efi/include/efidef.h
index 2d5d7ef..a770f03 100644
--- a/sys/boot/efi/include/efidef.h
+++ b/sys/boot/efi/include/efidef.h
@@ -30,7 +30,9 @@ Revision History
typedef UINT16 CHAR16;
typedef UINT8 CHAR8;
+#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
typedef UINT8 BOOLEAN;
+#endif
#ifndef TRUE
#define TRUE ((BOOLEAN) 1)
diff --git a/sys/boot/efi/include/i386/efibind.h b/sys/boot/efi/include/i386/efibind.h
index f28057b..de3658f 100644
--- a/sys/boot/efi/include/i386/efibind.h
+++ b/sys/boot/efi/include/i386/efibind.h
@@ -85,6 +85,9 @@ Revision History
// Basic EFI types of various widths
//
+#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine, use those */
+#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
+
typedef uint64_t UINT64;
typedef int64_t INT64;
@@ -98,6 +101,7 @@ typedef int16_t INT16;
typedef uint8_t UINT8;
typedef int8_t INT8;
+#endif
#undef VOID
#define VOID void
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 026b4ce..05eca21 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -1249,9 +1249,6 @@ t4_teardown_port_queues(struct port_info *pi)
free_ofld_rxq(pi, ofld_rxq);
}
#endif
-#ifdef DEV_NETMAP
- CXGBE_UNIMPLEMENTED(__func__);
-#endif
return (0);
}
diff --git a/sys/dev/ixl/i40e_adminq.c b/sys/dev/ixl/i40e_adminq.c
index 2dc0807..d769c45 100755
--- a/sys/dev/ixl/i40e_adminq.c
+++ b/sys/dev/ixl/i40e_adminq.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -614,7 +614,8 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
goto init_adminq_free_arq;
/* get the NVM version info */
- i40e_read_nvm_word(hw, I40E_SR_NVM_IMAGE_VERSION, &hw->nvm.version);
+ i40e_read_nvm_word(hw, I40E_SR_NVM_DEV_STARTER_VERSION,
+ &hw->nvm.version);
i40e_read_nvm_word(hw, I40E_SR_NVM_EETRACK_LO, &eetrack_lo);
i40e_read_nvm_word(hw, I40E_SR_NVM_EETRACK_HI, &eetrack_hi);
hw->nvm.eetrack = (eetrack_hi << 16) | eetrack_lo;
diff --git a/sys/dev/ixl/i40e_adminq_cmd.h b/sys/dev/ixl/i40e_adminq_cmd.h
index 02a3ea2..57b3ee1 100755
--- a/sys/dev/ixl/i40e_adminq_cmd.h
+++ b/sys/dev/ixl/i40e_adminq_cmd.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@
*/
#define I40E_FW_API_VERSION_MAJOR 0x0001
-#define I40E_FW_API_VERSION_MINOR 0x0002
+#define I40E_FW_API_VERSION_MINOR 0x0004
struct i40e_aq_desc {
__le16 flags;
@@ -140,12 +140,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_list_func_capabilities = 0x000A,
i40e_aqc_opc_list_dev_capabilities = 0x000B,
- i40e_aqc_opc_set_cppm_configuration = 0x0103,
- i40e_aqc_opc_set_arp_proxy_entry = 0x0104,
- i40e_aqc_opc_set_ns_proxy_entry = 0x0105,
-
/* LAA */
- i40e_aqc_opc_mng_laa = 0x0106, /* AQ obsolete */
i40e_aqc_opc_mac_address_read = 0x0107,
i40e_aqc_opc_mac_address_write = 0x0108,
@@ -270,7 +265,6 @@ enum i40e_admin_queue_opc {
/* Tunnel commands */
i40e_aqc_opc_add_udp_tunnel = 0x0B00,
i40e_aqc_opc_del_udp_tunnel = 0x0B01,
- i40e_aqc_opc_tunnel_key_structure = 0x0B10,
/* Async Events */
i40e_aqc_opc_event_lan_overflow = 0x1001,
@@ -282,8 +276,6 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_oem_ocbb_initialize = 0xFE03,
/* debug commands */
- i40e_aqc_opc_debug_get_deviceid = 0xFF00,
- i40e_aqc_opc_debug_set_mode = 0xFF01,
i40e_aqc_opc_debug_read_reg = 0xFF03,
i40e_aqc_opc_debug_write_reg = 0xFF04,
i40e_aqc_opc_debug_modify_reg = 0xFF07,
@@ -517,7 +509,8 @@ struct i40e_aqc_mac_address_read {
#define I40E_AQC_SAN_ADDR_VALID 0x20
#define I40E_AQC_PORT_ADDR_VALID 0x40
#define I40E_AQC_WOL_ADDR_VALID 0x80
-#define I40E_AQC_ADDR_VALID_MASK 0xf0
+#define I40E_AQC_MC_MAG_EN_VALID 0x100
+#define I40E_AQC_ADDR_VALID_MASK 0x1F0
u8 reserved[6];
__le32 addr_high;
__le32 addr_low;
@@ -540,7 +533,9 @@ struct i40e_aqc_mac_address_write {
#define I40E_AQC_WRITE_TYPE_LAA_ONLY 0x0000
#define I40E_AQC_WRITE_TYPE_LAA_WOL 0x4000
#define I40E_AQC_WRITE_TYPE_PORT 0x8000
-#define I40E_AQC_WRITE_TYPE_MASK 0xc000
+#define I40E_AQC_WRITE_TYPE_UPDATE_MC_MAG 0xC000
+#define I40E_AQC_WRITE_TYPE_MASK 0xC000
+
__le16 mac_sah;
__le32 mac_sal;
u8 reserved[8];
@@ -1076,6 +1071,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes {
__le16 seid;
#define I40E_AQC_VSI_PROM_CMD_SEID_MASK 0x3FF
__le16 vlan_tag;
+#define I40E_AQC_SET_VSI_VLAN_MASK 0x0FFF
#define I40E_AQC_SET_VSI_VLAN_VALID 0x8000
u8 reserved[8];
};
@@ -2070,6 +2066,12 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start);
#define I40E_AQC_CEE_PFC_STATUS_MASK (0x7 << I40E_AQC_CEE_PFC_STATUS_SHIFT)
#define I40E_AQC_CEE_APP_STATUS_SHIFT 0x8
#define I40E_AQC_CEE_APP_STATUS_MASK (0x7 << I40E_AQC_CEE_APP_STATUS_SHIFT)
+#define I40E_AQC_CEE_FCOE_STATUS_SHIFT 0x8
+#define I40E_AQC_CEE_FCOE_STATUS_MASK (0x7 << I40E_AQC_CEE_FCOE_STATUS_SHIFT)
+#define I40E_AQC_CEE_ISCSI_STATUS_SHIFT 0xA
+#define I40E_AQC_CEE_ISCSI_STATUS_MASK (0x7 << I40E_AQC_CEE_ISCSI_STATUS_SHIFT)
+#define I40E_AQC_CEE_FIP_STATUS_SHIFT 0x10
+#define I40E_AQC_CEE_FIP_STATUS_MASK (0x7 << I40E_AQC_CEE_FIP_STATUS_SHIFT)
struct i40e_aqc_get_cee_dcb_cfg_v1_resp {
u8 reserved1;
u8 oper_num_tc;
diff --git a/sys/dev/ixl/i40e_common.c b/sys/dev/ixl/i40e_common.c
index dfb60aa..f0f128e 100755
--- a/sys/dev/ixl/i40e_common.c
+++ b/sys/dev/ixl/i40e_common.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
#include "i40e_prototype.h"
#include "i40e_virtchnl.h"
+
/**
* i40e_set_mac_type - Sets MAC type
* @hw: pointer to the HW structure
@@ -61,6 +62,7 @@ enum i40e_status_code i40e_set_mac_type(struct i40e_hw *hw)
case I40E_DEV_ID_QSFP_B:
case I40E_DEV_ID_QSFP_C:
case I40E_DEV_ID_10G_BASE_T:
+ case I40E_DEV_ID_20G_KR2:
hw->mac.type = I40E_MAC_XL710;
break;
case I40E_DEV_ID_VF:
@@ -840,12 +842,15 @@ static enum i40e_media_type i40e_get_media_type(struct i40e_hw *hw)
case I40E_PHY_TYPE_10GBASE_CR1:
case I40E_PHY_TYPE_40GBASE_CR4:
case I40E_PHY_TYPE_10GBASE_SFPP_CU:
+ case I40E_PHY_TYPE_40GBASE_AOC:
+ case I40E_PHY_TYPE_10GBASE_AOC:
media = I40E_MEDIA_TYPE_DA;
break;
case I40E_PHY_TYPE_1000BASE_KX:
case I40E_PHY_TYPE_10GBASE_KX4:
case I40E_PHY_TYPE_10GBASE_KR:
case I40E_PHY_TYPE_40GBASE_KR4:
+ case I40E_PHY_TYPE_20GBASE_KR2:
media = I40E_MEDIA_TYPE_BACKPLANE;
break;
case I40E_PHY_TYPE_SGMII:
@@ -1508,6 +1513,10 @@ enum i40e_status_code i40e_aq_get_link_info(struct i40e_hw *hw,
else
hw_link_info->lse_enable = FALSE;
+ if ((hw->aq.fw_maj_ver < 4 || (hw->aq.fw_maj_ver == 4 &&
+ hw->aq.fw_min_ver < 40)) && hw_link_info->phy_type == 0xE)
+ hw_link_info->phy_type = I40E_PHY_TYPE_10GBASE_SFPP_CU;
+
/* save link status information */
if (link)
i40e_memcpy(link, hw_link_info, sizeof(*hw_link_info),
@@ -2807,12 +2816,13 @@ i40e_aq_erase_nvm_exit:
#define I40E_DEV_FUNC_CAP_MSIX_VF 0x44
#define I40E_DEV_FUNC_CAP_FLOW_DIRECTOR 0x45
#define I40E_DEV_FUNC_CAP_IEEE_1588 0x46
-#define I40E_DEV_FUNC_CAP_MFP_MODE_1 0xF1
+#define I40E_DEV_FUNC_CAP_FLEX10 0xF1
#define I40E_DEV_FUNC_CAP_CEM 0xF2
#define I40E_DEV_FUNC_CAP_IWARP 0x51
#define I40E_DEV_FUNC_CAP_LED 0x61
#define I40E_DEV_FUNC_CAP_SDP 0x62
#define I40E_DEV_FUNC_CAP_MDIO 0x63
+#define I40E_DEV_FUNC_CAP_WR_CSR_PROT 0x64
/**
* i40e_parse_discover_capabilities
@@ -2830,6 +2840,7 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
struct i40e_aqc_list_capabilities_element_resp *cap;
u32 valid_functions, num_functions;
u32 number, logical_id, phys_id;
+ u8 major_rev;
struct i40e_hw_capabilities *p;
u32 i = 0;
u16 id;
@@ -2848,6 +2859,7 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
number = LE32_TO_CPU(cap->number);
logical_id = LE32_TO_CPU(cap->logical_id);
phys_id = LE32_TO_CPU(cap->phys_id);
+ major_rev = cap->major_rev;
switch (id) {
case I40E_DEV_FUNC_CAP_SWITCH_MODE:
@@ -2922,9 +2934,21 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
case I40E_DEV_FUNC_CAP_MSIX_VF:
p->num_msix_vectors_vf = number;
break;
- case I40E_DEV_FUNC_CAP_MFP_MODE_1:
- if (number == 1)
- p->mfp_mode_1 = TRUE;
+ case I40E_DEV_FUNC_CAP_FLEX10:
+ if (major_rev == 1) {
+ if (number == 1) {
+ p->flex10_enable = TRUE;
+ p->flex10_capable = TRUE;
+ }
+ } else {
+ /* Capability revision >= 2 */
+ if (number & 1)
+ p->flex10_enable = TRUE;
+ if (number & 2)
+ p->flex10_capable = TRUE;
+ }
+ p->flex10_mode = logical_id;
+ p->flex10_status = phys_id;
break;
case I40E_DEV_FUNC_CAP_CEM:
if (number == 1)
@@ -2957,11 +2981,18 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
p->fd_filters_guaranteed = number;
p->fd_filters_best_effort = logical_id;
break;
+ case I40E_DEV_FUNC_CAP_WR_CSR_PROT:
+ p->wr_csr_prot = (u64)number;
+ p->wr_csr_prot |= (u64)logical_id << 32;
+ break;
default:
break;
}
}
+ if (p->fcoe)
+ i40e_debug(hw, I40E_DEBUG_ALL, "device is FCoE capable\n");
+
/* Always disable FCoE if compiled without the I40E_FCOE_ENA flag */
p->fcoe = FALSE;
@@ -4917,6 +4948,63 @@ void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status)
}
/**
+ * i40e_aq_debug_dump
+ * @hw: pointer to the hardware structure
+ * @cluster_id: specific cluster to dump
+ * @table_id: table id within cluster
+ * @start_index: index of line in the block to read
+ * @buff_size: dump buffer size
+ * @buff: dump buffer
+ * @ret_buff_size: actual buffer size returned
+ * @ret_next_table: next block to read
+ * @ret_next_index: next index to read
+ *
+ * Dump internal FW/HW data for debug purposes.
+ *
+ **/
+enum i40e_status_code i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
+ u8 table_id, u32 start_index, u16 buff_size,
+ void *buff, u16 *ret_buff_size,
+ u8 *ret_next_table, u32 *ret_next_index,
+ struct i40e_asq_cmd_details *cmd_details)
+{
+ struct i40e_aq_desc desc;
+ struct i40e_aqc_debug_dump_internals *cmd =
+ (struct i40e_aqc_debug_dump_internals *)&desc.params.raw;
+ struct i40e_aqc_debug_dump_internals *resp =
+ (struct i40e_aqc_debug_dump_internals *)&desc.params.raw;
+ enum i40e_status_code status;
+
+ if (buff_size == 0 || !buff)
+ return I40E_ERR_PARAM;
+
+ i40e_fill_default_direct_cmd_desc(&desc,
+ i40e_aqc_opc_debug_dump_internals);
+ /* Indirect Command */
+ desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+ if (buff_size > I40E_AQ_LARGE_BUF)
+ desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
+
+ cmd->cluster_id = cluster_id;
+ cmd->table_id = table_id;
+ cmd->idx = CPU_TO_LE32(start_index);
+
+ desc.datalen = CPU_TO_LE16(buff_size);
+
+ status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
+ if (!status) {
+ if (ret_buff_size != NULL)
+ *ret_buff_size = LE16_TO_CPU(desc.datalen);
+ if (ret_next_table != NULL)
+ *ret_next_table = resp->table_id;
+ if (ret_next_index != NULL)
+ *ret_next_index = LE32_TO_CPU(resp->idx);
+ }
+
+ return status;
+}
+
+/**
* i40e_read_bw_from_alt_ram
* @hw: pointer to the hardware structure
* @max_bw: pointer for max_bw read
diff --git a/sys/dev/ixl/i40e_lan_hmc.c b/sys/dev/ixl/i40e_lan_hmc.c
index 078adef..0866ad1 100755
--- a/sys/dev/ixl/i40e_lan_hmc.c
+++ b/sys/dev/ixl/i40e_lan_hmc.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -1218,7 +1218,7 @@ static enum i40e_status_code i40e_set_hmc_context(u8 *context_bytes,
/**
* i40e_hmc_get_object_va - retrieves an object's virtual address
- * @hmc_info: pointer to i40e_hmc_info struct
+ * @hw: pointer to the hw structure
* @object_base: pointer to u64 to get the va
* @rsrc_type: the hmc resource type
* @obj_idx: hmc object index
@@ -1227,12 +1227,13 @@ static enum i40e_status_code i40e_set_hmc_context(u8 *context_bytes,
* base pointer. This function is used for LAN Queue contexts.
**/
static
-enum i40e_status_code i40e_hmc_get_object_va(struct i40e_hmc_info *hmc_info,
+enum i40e_status_code i40e_hmc_get_object_va(struct i40e_hw *hw,
u8 **object_base,
enum i40e_hmc_lan_rsrc_type rsrc_type,
u32 obj_idx)
{
u32 obj_offset_in_sd, obj_offset_in_pd;
+ struct i40e_hmc_info *hmc_info = &hw->hmc;
struct i40e_hmc_sd_entry *sd_entry;
struct i40e_hmc_pd_entry *pd_entry;
u32 pd_idx, pd_lmt, rel_pd_idx;
@@ -1304,8 +1305,7 @@ enum i40e_status_code i40e_get_lan_tx_queue_context(struct i40e_hw *hw,
enum i40e_status_code err;
u8 *context_bytes;
- err = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,
- I40E_HMC_LAN_TX, queue);
+ err = i40e_hmc_get_object_va(hw, &context_bytes, I40E_HMC_LAN_TX, queue);
if (err < 0)
return err;
@@ -1324,8 +1324,7 @@ enum i40e_status_code i40e_clear_lan_tx_queue_context(struct i40e_hw *hw,
enum i40e_status_code err;
u8 *context_bytes;
- err = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,
- I40E_HMC_LAN_TX, queue);
+ err = i40e_hmc_get_object_va(hw, &context_bytes, I40E_HMC_LAN_TX, queue);
if (err < 0)
return err;
@@ -1345,8 +1344,7 @@ enum i40e_status_code i40e_set_lan_tx_queue_context(struct i40e_hw *hw,
enum i40e_status_code err;
u8 *context_bytes;
- err = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,
- I40E_HMC_LAN_TX, queue);
+ err = i40e_hmc_get_object_va(hw, &context_bytes, I40E_HMC_LAN_TX, queue);
if (err < 0)
return err;
@@ -1367,8 +1365,7 @@ enum i40e_status_code i40e_get_lan_rx_queue_context(struct i40e_hw *hw,
enum i40e_status_code err;
u8 *context_bytes;
- err = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,
- I40E_HMC_LAN_RX, queue);
+ err = i40e_hmc_get_object_va(hw, &context_bytes, I40E_HMC_LAN_RX, queue);
if (err < 0)
return err;
@@ -1387,8 +1384,7 @@ enum i40e_status_code i40e_clear_lan_rx_queue_context(struct i40e_hw *hw,
enum i40e_status_code err;
u8 *context_bytes;
- err = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,
- I40E_HMC_LAN_RX, queue);
+ err = i40e_hmc_get_object_va(hw, &context_bytes, I40E_HMC_LAN_RX, queue);
if (err < 0)
return err;
@@ -1408,8 +1404,7 @@ enum i40e_status_code i40e_set_lan_rx_queue_context(struct i40e_hw *hw,
enum i40e_status_code err;
u8 *context_bytes;
- err = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,
- I40E_HMC_LAN_RX, queue);
+ err = i40e_hmc_get_object_va(hw, &context_bytes, I40E_HMC_LAN_RX, queue);
if (err < 0)
return err;
diff --git a/sys/dev/ixl/i40e_prototype.h b/sys/dev/ixl/i40e_prototype.h
index 2b72383..fc4907e 100755
--- a/sys/dev/ixl/i40e_prototype.h
+++ b/sys/dev/ixl/i40e_prototype.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -445,4 +445,9 @@ enum i40e_status_code i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
u16 vsi_seid, u16 queue, bool is_add,
struct i40e_control_filter_stats *stats,
struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
+ u8 table_id, u32 start_index, u16 buff_size,
+ void *buff, u16 *ret_buff_size,
+ u8 *ret_next_table, u32 *ret_next_index,
+ struct i40e_asq_cmd_details *cmd_details);
#endif /* _I40E_PROTOTYPE_H_ */
diff --git a/sys/dev/ixl/i40e_type.h b/sys/dev/ixl/i40e_type.h
index 703fae1..7fe50e2 100755
--- a/sys/dev/ixl/i40e_type.h
+++ b/sys/dev/ixl/i40e_type.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -57,6 +57,7 @@
#define I40E_DEV_ID_QSFP_B 0x1584
#define I40E_DEV_ID_QSFP_C 0x1585
#define I40E_DEV_ID_10G_BASE_T 0x1586
+#define I40E_DEV_ID_20G_KR2 0x1587
#define I40E_DEV_ID_VF 0x154C
#define I40E_DEV_ID_VF_HV 0x1571
@@ -286,7 +287,17 @@ struct i40e_hw_capabilities {
bool dcb;
bool fcoe;
bool iscsi; /* Indicates iSCSI enabled */
- bool mfp_mode_1;
+ bool flex10_enable;
+ bool flex10_capable;
+ u32 flex10_mode;
+#define I40E_FLEX10_MODE_UNKNOWN 0x0
+#define I40E_FLEX10_MODE_DCC 0x1
+#define I40E_FLEX10_MODE_DCI 0x2
+
+ u32 flex10_status;
+#define I40E_FLEX10_STATUS_DCC_ERROR 0x1
+#define I40E_FLEX10_STATUS_VC_MODE 0x2
+
bool mgmt_cem;
bool ieee_1588;
bool iwarp;
@@ -315,6 +326,7 @@ struct i40e_hw_capabilities {
u8 rx_buf_chain_len;
u32 enabled_tcmap;
u32 maxtc;
+ u64 wr_csr_prot;
};
struct i40e_mac_info {
@@ -560,7 +572,11 @@ struct i40e_hw {
/* debug mask */
u32 debug_mask;
};
-#define i40e_is_vf(_hw) ((_hw)->mac.type == I40E_MAC_VF)
+
+static INLINE bool i40e_is_vf(struct i40e_hw *hw)
+{
+ return hw->mac.type == I40E_MAC_VF;
+}
struct i40e_driver_version {
u8 major_version;
@@ -1258,6 +1274,9 @@ struct i40e_hw_port_stats {
/* flow director stats */
u64 fd_atr_match;
u64 fd_sb_match;
+ u64 fd_atr_tunnel_match;
+ u32 fd_atr_status;
+ u32 fd_sb_status;
/* EEE LPI */
u32 tx_lpi_status;
u32 rx_lpi_status;
diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c
index da3b38b..e631030 100755
--- a/sys/dev/ixl/if_ixl.c
+++ b/sys/dev/ixl/if_ixl.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -32,9 +32,12 @@
******************************************************************************/
/*$FreeBSD$*/
+#ifndef IXL_STANDALONE_BUILD
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_rss.h"
+#endif
+
#include "ixl.h"
#include "ixl_pf.h"
@@ -45,7 +48,7 @@
/*********************************************************************
* Driver version
*********************************************************************/
-char ixl_driver_version[] = "1.3.1";
+char ixl_driver_version[] = "1.3.6";
/*********************************************************************
* PCI Device ID Table
@@ -99,7 +102,7 @@ static void ixl_update_link_status(struct ixl_pf *);
static int ixl_allocate_pci_resources(struct ixl_pf *);
static u16 ixl_get_bus_info(struct i40e_hw *, device_t);
static int ixl_setup_stations(struct ixl_pf *);
-static int ixl_setup_vsi(struct ixl_vsi *);
+static int ixl_switch_config(struct ixl_pf *);
static int ixl_initialize_vsi(struct ixl_vsi *);
static int ixl_assign_vsi_msix(struct ixl_pf *);
static int ixl_assign_vsi_legacy(struct ixl_pf *);
@@ -499,48 +502,6 @@ ixl_attach(device_t dev)
goto err_out;
}
- /* For now always do an initial CORE reset on first device */
- {
- static int ixl_dev_count;
- static int ixl_dev_track[32];
- u32 my_dev;
- int i, found = FALSE;
- u16 bus = pci_get_bus(dev);
-
- mtx_lock(&ixl_reset_mtx);
- my_dev = (bus << 8) | hw->bus.device;
-
- for (i = 0; i < ixl_dev_count; i++) {
- if (ixl_dev_track[i] == my_dev)
- found = TRUE;
- }
-
- if (!found) {
- u32 reg;
-
- ixl_dev_track[ixl_dev_count] = my_dev;
- ixl_dev_count++;
-
- INIT_DEBUGOUT("Initial CORE RESET\n");
- wr32(hw, I40E_GLGEN_RTRIG, I40E_GLGEN_RTRIG_CORER_MASK);
- ixl_flush(hw);
- i = 50;
- do {
- i40e_msec_delay(50);
- reg = rd32(hw, I40E_GLGEN_RSTAT);
- if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
- break;
- } while (i--);
-
- /* paranoia */
- wr32(hw, I40E_PF_ATQLEN, 0);
- wr32(hw, I40E_PF_ATQBAL, 0);
- wr32(hw, I40E_PF_ATQBAH, 0);
- i40e_clear_pxe_mode(hw);
- }
- mtx_unlock(&ixl_reset_mtx);
- }
-
/* Set admin queue parameters */
hw->aq.num_arq_entries = IXL_AQ_LEN;
hw->aq.num_asq_entries = IXL_AQ_LEN;
@@ -630,13 +591,15 @@ ixl_attach(device_t dev)
if (error)
goto err_late;
- i40e_msec_delay(75);
- error = i40e_aq_set_link_restart_an(hw, TRUE, NULL);
- if (error) {
- device_printf(dev, "link restart failed, aq_err=%d\n",
- pf->hw.aq.asq_last_status);
+ if (((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver < 33)) ||
+ (hw->aq.fw_maj_ver < 4)) {
+ i40e_msec_delay(75);
+ error = i40e_aq_set_link_restart_an(hw, TRUE, NULL);
+ if (error)
+ device_printf(dev, "link restart failed, aq_err=%d\n",
+ pf->hw.aq.asq_last_status);
}
-
+
/* Determine link state */
vsi->link_up = ixl_config_link(hw);
@@ -656,6 +619,18 @@ ixl_attach(device_t dev)
goto err_late;
}
+ error = ixl_switch_config(pf);
+ if (error) {
+ device_printf(dev, "Initial switch config failed: %d\n", error);
+ goto err_mac_hmc;
+ }
+
+ /* Limit phy interrupts to link and modules failure */
+ error = i40e_aq_set_phy_int_mask(hw,
+ I40E_AQ_EVENT_LINK_UPDOWN | I40E_AQ_EVENT_MODULE_QUAL_FAIL, NULL);
+ if (error)
+ device_printf(dev, "set phy mask failed: %d\n", error);
+
/* Get the bus configuration and set the shared code */
bus = ixl_get_bus_info(hw, dev);
i40e_set_pci_config_data(hw, bus);
@@ -665,13 +640,6 @@ ixl_attach(device_t dev)
ixl_update_stats_counters(pf);
ixl_add_hw_stats(pf);
- /* Reset port's advertised speeds */
- if (!i40e_is_40G_device(hw->device_id)) {
- pf->advertised_speed =
- (hw->device_id == I40E_DEV_ID_10G_BASE_T) ? 0x7 : 0x6;
- ixl_set_advertised_speeds(pf, pf->advertised_speed);
- }
-
/* Register for VLAN events */
vsi->vlan_attach = EVENTHANDLER_REGISTER(vlan_config,
ixl_register_vlan, vsi, EVENTHANDLER_PRI_FIRST);
@@ -723,9 +691,12 @@ ixl_detach(device_t dev)
return (EBUSY);
}
- IXL_PF_LOCK(pf);
- ixl_stop(pf);
- IXL_PF_UNLOCK(pf);
+ ether_ifdetach(vsi->ifp);
+ if (vsi->ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ IXL_PF_LOCK(pf);
+ ixl_stop(pf);
+ IXL_PF_UNLOCK(pf);
+ }
for (int i = 0; i < vsi->num_queues; i++, que++) {
if (que->tq) {
@@ -753,7 +724,6 @@ ixl_detach(device_t dev)
if (vsi->vlan_detach != NULL)
EVENTHANDLER_DEREGISTER(vlan_unconfig, vsi->vlan_detach);
- ether_ifdetach(vsi->ifp);
callout_drain(&pf->timer);
@@ -1122,11 +1092,8 @@ ixl_init_locked(struct ixl_pf *pf)
/* Set up RSS */
ixl_config_rss(vsi);
- /* Setup the VSI */
- ixl_setup_vsi(vsi);
-
/*
- ** Prepare the rings, hmc contexts, etc...
+ ** Prepare the VSI: rings, hmc contexts, etc...
*/
if (ixl_initialize_vsi(vsi)) {
device_printf(dev, "initialize vsi failed!!\n");
@@ -1409,16 +1376,14 @@ ixl_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
ifmr->ifm_active |= IFM_1000_LX;
break;
/* 10 G */
+ case I40E_PHY_TYPE_10GBASE_CR1:
case I40E_PHY_TYPE_10GBASE_CR1_CU:
case I40E_PHY_TYPE_10GBASE_SFPP_CU:
+ /* Using this until a real KR media type */
+ case I40E_PHY_TYPE_10GBASE_KR:
+ case I40E_PHY_TYPE_10GBASE_KX4:
ifmr->ifm_active |= IFM_10G_TWINAX;
break;
- case I40E_PHY_TYPE_10GBASE_KR:
- /*
- ** this is not technically correct
- ** but FreeBSD does not have the media
- ** type defined yet, so its a compromise.
- */
case I40E_PHY_TYPE_10GBASE_SR:
ifmr->ifm_active |= IFM_10G_SR;
break;
@@ -1439,6 +1404,16 @@ ixl_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
case I40E_PHY_TYPE_40GBASE_LR4:
ifmr->ifm_active |= IFM_40G_LR4;
break;
+ /*
+ ** Set these to CR4 because OS does not
+ ** have types available yet.
+ */
+ case I40E_PHY_TYPE_40GBASE_KR4:
+ case I40E_PHY_TYPE_XLAUI:
+ case I40E_PHY_TYPE_XLPPI:
+ case I40E_PHY_TYPE_40GBASE_AOC:
+ ifmr->ifm_active |= IFM_40G_CR4;
+ break;
default:
ifmr->ifm_active |= IFM_UNKNOWN;
break;
@@ -1765,18 +1740,17 @@ ixl_update_link_status(struct ixl_pf *pf)
struct i40e_hw *hw = &pf->hw;
struct ifnet *ifp = vsi->ifp;
device_t dev = pf->dev;
- enum i40e_fc_mode fc;
if (vsi->link_up){
if (vsi->link_active == FALSE) {
i40e_aq_get_link_info(hw, TRUE, NULL, NULL);
+ pf->fc = hw->fc.current_mode;
if (bootverbose) {
- fc = hw->fc.current_mode;
device_printf(dev,"Link is up %d Gbps %s,"
" Flow Control: %s\n",
((vsi->link_speed == I40E_LINK_SPEED_40GB)? 40:10),
- "Full Duplex", ixl_fc_string[fc]);
+ "Full Duplex", ixl_fc_string[pf->fc]);
}
vsi->link_active = TRUE;
/*
@@ -2341,8 +2315,15 @@ ixl_add_ifmedia(struct ixl_vsi *vsi, u32 phy_type)
ifmedia_add(&vsi->media, IFM_ETHER | IFM_1000_T, 0, NULL);
if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_CR1_CU) ||
+ phy_type & (1 << I40E_PHY_TYPE_10GBASE_KX4) ||
+ phy_type & (1 << I40E_PHY_TYPE_10GBASE_KR) ||
+ phy_type & (1 << I40E_PHY_TYPE_10GBASE_AOC) ||
+ phy_type & (1 << I40E_PHY_TYPE_XAUI) ||
+ phy_type & (1 << I40E_PHY_TYPE_XFI) ||
+ phy_type & (1 << I40E_PHY_TYPE_SFI) ||
phy_type & (1 << I40E_PHY_TYPE_10GBASE_SFPP_CU))
ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_TWINAX, 0, NULL);
+
if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_SR))
ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_SR, 0, NULL);
if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_LR))
@@ -2350,9 +2331,15 @@ ixl_add_ifmedia(struct ixl_vsi *vsi, u32 phy_type)
if (phy_type & (1 << I40E_PHY_TYPE_10GBASE_T))
ifmedia_add(&vsi->media, IFM_ETHER | IFM_10G_T, 0, NULL);
- if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4_CU) ||
- phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4))
+ if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4) ||
+ phy_type & (1 << I40E_PHY_TYPE_40GBASE_CR4_CU) ||
+ phy_type & (1 << I40E_PHY_TYPE_40GBASE_AOC) ||
+ phy_type & (1 << I40E_PHY_TYPE_XLAUI) ||
+ phy_type & (1 << I40E_PHY_TYPE_XLPPI) ||
+ /* KR4 uses CR4 until the OS has the real media type */
+ phy_type & (1 << I40E_PHY_TYPE_40GBASE_KR4))
ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_CR4, 0, NULL);
+
if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_SR4))
ifmedia_add(&vsi->media, IFM_ETHER | IFM_40G_SR4, 0, NULL);
if (phy_type & (1 << I40E_PHY_TYPE_40GBASE_LR4))
@@ -2370,7 +2357,7 @@ ixl_setup_interface(device_t dev, struct ixl_vsi *vsi)
struct ifnet *ifp;
struct i40e_hw *hw = vsi->hw;
struct ixl_queue *que = vsi->queues;
- struct i40e_aq_get_phy_abilities_resp abilities_resp;
+ struct i40e_aq_get_phy_abilities_resp abilities;
enum i40e_status_code aq_error = 0;
INIT_DEBUGOUT("ixl_setup_interface: begin");
@@ -2437,21 +2424,25 @@ ixl_setup_interface(device_t dev, struct ixl_vsi *vsi)
ifmedia_init(&vsi->media, IFM_IMASK, ixl_media_change,
ixl_media_status);
- aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, TRUE, &abilities_resp, NULL);
+ aq_error = i40e_aq_get_phy_capabilities(hw,
+ FALSE, TRUE, &abilities, NULL);
+ /* May need delay to detect fiber correctly */
if (aq_error == I40E_ERR_UNKNOWN_PHY) {
- /* Need delay to detect fiber correctly */
i40e_msec_delay(200);
aq_error = i40e_aq_get_phy_capabilities(hw, FALSE,
- TRUE, &abilities_resp, NULL);
+ TRUE, &abilities, NULL);
+ }
+ if (aq_error) {
if (aq_error == I40E_ERR_UNKNOWN_PHY)
device_printf(dev, "Unknown PHY type detected!\n");
else
- ixl_add_ifmedia(vsi, abilities_resp.phy_type);
- } else if (aq_error) {
- device_printf(dev, "Error getting supported media types, err %d,"
- " AQ error %d\n", aq_error, hw->aq.asq_last_status);
- } else
- ixl_add_ifmedia(vsi, abilities_resp.phy_type);
+ device_printf(dev,
+ "Error getting supported media types, err %d,"
+ " AQ error %d\n", aq_error, hw->aq.asq_last_status);
+ return (0);
+ }
+
+ ixl_add_ifmedia(vsi, abilities.phy_type);
/* Use autoselect media by default */
ifmedia_add(&vsi->media, IFM_ETHER | IFM_AUTO, 0, NULL);
@@ -2477,20 +2468,23 @@ ixl_config_link(struct i40e_hw *hw)
/*********************************************************************
*
- * Initialize this VSI
+ * Get Firmware Switch configuration
+ * - this will need to be more robust when more complex
+ * switch configurations are enabled.
*
**********************************************************************/
static int
-ixl_setup_vsi(struct ixl_vsi *vsi)
+ixl_switch_config(struct ixl_pf *pf)
{
- struct i40e_hw *hw = vsi->hw;
+ struct i40e_hw *hw = &pf->hw;
+ struct ixl_vsi *vsi = &pf->vsi;
device_t dev = vsi->dev;
struct i40e_aqc_get_switch_config_resp *sw_config;
- struct i40e_vsi_context ctxt;
u8 aq_buf[I40E_AQ_LARGE_BUF];
int ret = I40E_SUCCESS;
u16 next = 0;
+ memset(&aq_buf, 0, sizeof(aq_buf));
sw_config = (struct i40e_aqc_get_switch_config_resp *)aq_buf;
ret = i40e_aq_get_switch_config(hw, sw_config,
sizeof(aq_buf), &next, NULL);
@@ -2507,16 +2501,34 @@ ixl_setup_vsi(struct ixl_vsi *vsi)
sw_config->element[0].uplink_seid,
sw_config->element[0].downlink_seid);
#endif
- /* Save off this important value */
+ /* Simplified due to a single VSI at the moment */
vsi->seid = sw_config->element[0].seid;
+ return (ret);
+}
+
+/*********************************************************************
+ *
+ * Initialize the VSI: this handles contexts, which means things
+ * like the number of descriptors, buffer size,
+ * plus we init the rings thru this function.
+ *
+ **********************************************************************/
+static int
+ixl_initialize_vsi(struct ixl_vsi *vsi)
+{
+ struct ixl_queue *que = vsi->queues;
+ device_t dev = vsi->dev;
+ struct i40e_hw *hw = vsi->hw;
+ struct i40e_vsi_context ctxt;
+ int err = 0;
memset(&ctxt, 0, sizeof(ctxt));
ctxt.seid = vsi->seid;
ctxt.pf_num = hw->pf_id;
- ret = i40e_aq_get_vsi_params(hw, &ctxt, NULL);
- if (ret) {
- device_printf(dev,"get vsi params failed %x!!\n", ret);
- return (ret);
+ err = i40e_aq_get_vsi_params(hw, &ctxt, NULL);
+ if (err) {
+ device_printf(dev,"get vsi params failed %x!!\n", err);
+ return (err);
}
#ifdef IXL_DEBUG
printf("get_vsi_params: seid: %d, uplinkseid: %d, vsi_number: %d, "
@@ -2553,29 +2565,12 @@ ixl_setup_vsi(struct ixl_vsi *vsi)
vsi->hw_filters_add = 0;
vsi->hw_filters_del = 0;
- ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
- if (ret)
+ err = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
+ if (err) {
device_printf(dev,"update vsi params failed %x!!\n",
hw->aq.asq_last_status);
- return (ret);
-}
-
-
-/*********************************************************************
- *
- * Initialize the VSI: this handles contexts, which means things
- * like the number of descriptors, buffer size,
- * plus we init the rings thru this function.
- *
- **********************************************************************/
-static int
-ixl_initialize_vsi(struct ixl_vsi *vsi)
-{
- struct ixl_queue *que = vsi->queues;
- device_t dev = vsi->dev;
- struct i40e_hw *hw = vsi->hw;
- int err = 0;
-
+ return (err);
+ }
for (int i = 0; i < vsi->num_queues; i++, que++) {
struct tx_ring *txr = &que->txr;
@@ -3216,7 +3211,7 @@ static void ixl_config_rss(struct ixl_vsi *vsi)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP);
if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
- if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
+ if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
@@ -3521,8 +3516,8 @@ ixl_add_hw_filters(struct ixl_vsi *vsi, int flags, int cnt)
if (j > 0) {
err = i40e_aq_add_macvlan(hw, vsi->seid, a, j, NULL);
if (err)
- device_printf(dev, "aq_add_macvlan err %d, aq_error %d\n",
- err, hw->aq.asq_last_status);
+ device_printf(dev, "aq_add_macvlan err %d, "
+ "aq_error %d\n", err, hw->aq.asq_last_status);
else
vsi->hw_filters_add += j;
}
@@ -4307,24 +4302,15 @@ ixl_set_flowcntl(SYSCTL_HANDLER_ARGS)
struct ixl_pf *pf = (struct ixl_pf *)arg1;
struct i40e_hw *hw = &pf->hw;
device_t dev = pf->dev;
- int requested_fc = 0, error = 0;
+ int error = 0;
enum i40e_status_code aq_error = 0;
u8 fc_aq_err = 0;
- aq_error = i40e_aq_get_link_info(hw, TRUE, NULL, NULL);
- if (aq_error) {
- device_printf(dev,
- "%s: Error retrieving link info from aq, %d\n",
- __func__, aq_error);
- return (EAGAIN);
- }
-
- /* Read in new mode */
- requested_fc = hw->fc.current_mode;
- error = sysctl_handle_int(oidp, &requested_fc, 0, req);
+ /* Get request */
+ error = sysctl_handle_int(oidp, &pf->fc, 0, req);
if ((error) || (req->newptr == NULL))
return (error);
- if (requested_fc < 0 || requested_fc > 3) {
+ if (pf->fc < 0 || pf->fc > 3) {
device_printf(dev,
"Invalid fc mode; valid modes are 0 through 3\n");
return (EINVAL);
@@ -4342,7 +4328,7 @@ ixl_set_flowcntl(SYSCTL_HANDLER_ARGS)
}
/* Set fc ability for port */
- hw->fc.requested_mode = requested_fc;
+ hw->fc.requested_mode = pf->fc;
aq_error = i40e_set_fc(hw, &fc_aq_err, TRUE);
if (aq_error) {
device_printf(dev,
@@ -4351,14 +4337,6 @@ ixl_set_flowcntl(SYSCTL_HANDLER_ARGS)
return (EAGAIN);
}
- if (hw->fc.current_mode != hw->fc.requested_mode) {
- device_printf(dev, "%s: FC set failure:\n", __func__);
- device_printf(dev, "%s: Current: %s / Requested: %s\n",
- __func__,
- ixl_fc_string[hw->fc.current_mode],
- ixl_fc_string[hw->fc.requested_mode]);
- }
-
return (0);
}
@@ -4417,9 +4395,11 @@ ixl_set_advertised_speeds(struct ixl_pf *pf, int speeds)
enum i40e_status_code aq_error = 0;
/* Get current capability information */
- aq_error = i40e_aq_get_phy_capabilities(hw, FALSE, FALSE, &abilities, NULL);
+ aq_error = i40e_aq_get_phy_capabilities(hw,
+ FALSE, FALSE, &abilities, NULL);
if (aq_error) {
- device_printf(dev, "%s: Error getting phy capabilities %d,"
+ device_printf(dev,
+ "%s: Error getting phy capabilities %d,"
" aq error: %d\n", __func__, aq_error,
hw->aq.asq_last_status);
return (EAGAIN);
@@ -4444,7 +4424,8 @@ ixl_set_advertised_speeds(struct ixl_pf *pf, int speeds)
/* Do aq command & restart link */
aq_error = i40e_aq_set_phy_config(hw, &config, NULL);
if (aq_error) {
- device_printf(dev, "%s: Error setting new phy config %d,"
+ device_printf(dev,
+ "%s: Error setting new phy config %d,"
" aq error: %d\n", __func__, aq_error,
hw->aq.asq_last_status);
return (EAGAIN);
diff --git a/sys/dev/ixl/if_ixlv.c b/sys/dev/ixl/if_ixlv.c
index 523c7ce..f1e106e 100644
--- a/sys/dev/ixl/if_ixlv.c
+++ b/sys/dev/ixl/if_ixlv.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -32,9 +32,12 @@
******************************************************************************/
/*$FreeBSD$*/
+#ifndef IXL_STANDALONE_BUILD
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_rss.h"
+#endif
+
#include "ixl.h"
#include "ixlv.h"
@@ -1819,8 +1822,7 @@ ixlv_msix_adminq(void *arg)
{
struct ixlv_sc *sc = arg;
struct i40e_hw *hw = &sc->hw;
- device_t dev = sc->dev;
- u32 reg, mask, oldreg;
+ u32 reg, mask;
reg = rd32(hw, I40E_VFINT_ICR01);
mask = rd32(hw, I40E_VFINT_ICR0_ENA1);
@@ -1829,43 +1831,6 @@ ixlv_msix_adminq(void *arg)
reg |= I40E_PFINT_DYN_CTL0_CLEARPBA_MASK;
wr32(hw, I40E_VFINT_DYN_CTL01, reg);
- /* check for Admin queue errors */
- oldreg = reg = rd32(hw, hw->aq.arq.len);
- if (reg & I40E_VF_ARQLEN_ARQVFE_MASK) {
- device_printf(dev, "ARQ VF Error detected\n");
- reg &= ~I40E_VF_ARQLEN_ARQVFE_MASK;
- }
- if (reg & I40E_VF_ARQLEN_ARQOVFL_MASK) {
- device_printf(dev, "ARQ Overflow Error detected\n");
- reg &= ~I40E_VF_ARQLEN_ARQOVFL_MASK;
- }
- if (reg & I40E_VF_ARQLEN_ARQCRIT_MASK) {
- device_printf(dev, "ARQ Critical Error detected\n");
- reg &= ~I40E_VF_ARQLEN_ARQCRIT_MASK;
- }
- if (oldreg != reg)
- wr32(hw, hw->aq.arq.len, reg);
-
- oldreg = reg = rd32(hw, hw->aq.asq.len);
- if (reg & I40E_VF_ATQLEN_ATQVFE_MASK) {
- device_printf(dev, "ASQ VF Error detected\n");
- reg &= ~I40E_VF_ATQLEN_ATQVFE_MASK;
- }
- if (reg & I40E_VF_ATQLEN_ATQOVFL_MASK) {
- device_printf(dev, "ASQ Overflow Error detected\n");
- reg &= ~I40E_VF_ATQLEN_ATQOVFL_MASK;
- }
- if (reg & I40E_VF_ATQLEN_ATQCRIT_MASK) {
- device_printf(dev, "ASQ Critical Error detected\n");
- reg &= ~I40E_VF_ATQLEN_ATQCRIT_MASK;
- }
- if (oldreg != reg)
- wr32(hw, hw->aq.asq.len, reg);
-
- /* re-enable interrupt causes */
- wr32(hw, I40E_VFINT_ICR0_ENA1, mask);
- wr32(hw, I40E_VFINT_DYN_CTL01, I40E_VFINT_DYN_CTL01_INTENA_MASK);
-
/* schedule task */
taskqueue_enqueue(sc->tq, &sc->aq_irq);
return;
@@ -2600,7 +2565,7 @@ ixlv_config_rss(struct ixlv_sc *sc)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV4_UDP);
if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER);
- if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
+ if (rss_hash_config & RSS_HASHTYPE_RSS_IPV6_EX)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_FRAG_IPV6);
if (rss_hash_config & RSS_HASHTYPE_RSS_TCP_IPV6)
set_hena |= ((u64)1 << I40E_FILTER_PCTYPE_NONF_IPV6_TCP);
@@ -2752,8 +2717,10 @@ ixlv_do_adminq_locked(struct ixlv_sc *sc)
struct i40e_hw *hw = &sc->hw;
struct i40e_arq_event_info event;
struct i40e_virtchnl_msg *v_msg;
- i40e_status ret;
+ device_t dev = sc->dev;
u16 result = 0;
+ u32 reg, oldreg;
+ i40e_status ret;
IXLV_CORE_LOCK_ASSERT(sc);
@@ -2771,6 +2738,39 @@ ixlv_do_adminq_locked(struct ixlv_sc *sc)
bzero(event.msg_buf, IXL_AQ_BUF_SZ);
} while (result);
+ /* check for Admin queue errors */
+ oldreg = reg = rd32(hw, hw->aq.arq.len);
+ if (reg & I40E_VF_ARQLEN_ARQVFE_MASK) {
+ device_printf(dev, "ARQ VF Error detected\n");
+ reg &= ~I40E_VF_ARQLEN_ARQVFE_MASK;
+ }
+ if (reg & I40E_VF_ARQLEN_ARQOVFL_MASK) {
+ device_printf(dev, "ARQ Overflow Error detected\n");
+ reg &= ~I40E_VF_ARQLEN_ARQOVFL_MASK;
+ }
+ if (reg & I40E_VF_ARQLEN_ARQCRIT_MASK) {
+ device_printf(dev, "ARQ Critical Error detected\n");
+ reg &= ~I40E_VF_ARQLEN_ARQCRIT_MASK;
+ }
+ if (oldreg != reg)
+ wr32(hw, hw->aq.arq.len, reg);
+
+ oldreg = reg = rd32(hw, hw->aq.asq.len);
+ if (reg & I40E_VF_ATQLEN_ATQVFE_MASK) {
+ device_printf(dev, "ASQ VF Error detected\n");
+ reg &= ~I40E_VF_ATQLEN_ATQVFE_MASK;
+ }
+ if (reg & I40E_VF_ATQLEN_ATQOVFL_MASK) {
+ device_printf(dev, "ASQ Overflow Error detected\n");
+ reg &= ~I40E_VF_ATQLEN_ATQOVFL_MASK;
+ }
+ if (reg & I40E_VF_ATQLEN_ATQCRIT_MASK) {
+ device_printf(dev, "ASQ Critical Error detected\n");
+ reg &= ~I40E_VF_ATQLEN_ATQCRIT_MASK;
+ }
+ if (oldreg != reg)
+ wr32(hw, hw->aq.asq.len, reg);
+
ixlv_enable_adminq_irq(hw);
}
diff --git a/sys/dev/ixl/ixl.h b/sys/dev/ixl/ixl.h
index 39d9137..30e195f 100644
--- a/sys/dev/ixl/ixl.h
+++ b/sys/dev/ixl/ixl.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -208,7 +208,9 @@
#define IXL_TX_BUF_SZ ((u32) 1514)
#define IXL_AQ_BUF_SZ ((u32) 4096)
#define IXL_RX_HDR 128
+/* Controls the length of the Admin Queue */
#define IXL_AQ_LEN 256
+#define IXL_AQ_LEN_MAX 1024
#define IXL_AQ_BUFSZ 4096
#define IXL_RX_LIMIT 512
#define IXL_RX_ITR 0
@@ -273,7 +275,7 @@
#define IXL_RX_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
#define IXL_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx)
-#if __FreeBSD_version >= 1100000
+#if __FreeBSD_version >= 1100036
#define IXL_SET_IPACKETS(vsi, count) (vsi)->ipackets = (count)
#define IXL_SET_IERRORS(vsi, count) (vsi)->ierrors = (count)
#define IXL_SET_OPACKETS(vsi, count) (vsi)->opackets = (count)
@@ -469,7 +471,6 @@ struct ixl_vsi {
u16 max_frame_size;
u32 link_speed;
bool link_up;
- u32 fc; /* local flow ctrl setting */
/* MAC/VLAN Filter list */
struct ixl_ftl_head ftl;
diff --git a/sys/dev/ixl/ixl_pf.h b/sys/dev/ixl/ixl_pf.h
index 055c54f..7c3d3bb 100644
--- a/sys/dev/ixl/ixl_pf.h
+++ b/sys/dev/ixl/ixl_pf.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ struct ixl_pf {
struct taskqueue *tq;
int advertised_speed;
+ int fc; /* local flow ctrl setting */
/*
** VSI - Stations:
diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c
index 6a6ab7c..89b07d1 100755
--- a/sys/dev/ixl/ixl_txrx.c
+++ b/sys/dev/ixl/ixl_txrx.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -38,12 +38,15 @@
** both the BASE and the VF drivers.
*/
+#ifndef IXL_STANDALONE_BUILD
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_rss.h"
+#endif
+
#include "ixl.h"
-#ifdef RSS
+#ifdef RSS
#include <net/rss_config.h>
#endif
@@ -1371,7 +1374,7 @@ ixl_rx_discard(struct rx_ring *rxr, int i)
#ifdef RSS
/*
-** ixl_ptype_to_hash: parse the packet type
+** i40e_ptype_to_hash: parse the packet type
** to determine the appropriate hash.
*/
static inline int
diff --git a/sys/dev/ixl/ixlvc.c b/sys/dev/ixl/ixlvc.c
index aa81bc1..a0142ba 100644
--- a/sys/dev/ixl/ixlvc.c
+++ b/sys/dev/ixl/ixlvc.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2013-2014, Intel Corporation
+ Copyright (c) 2013-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -770,11 +770,16 @@ void
ixlv_request_stats(struct ixlv_sc *sc)
{
struct i40e_virtchnl_queue_select vqs;
+ int error = 0;
vqs.vsi_id = sc->vsi_res->vsi_id;
/* Low priority, we don't need to error check */
- ixlv_send_pf_msg(sc, I40E_VIRTCHNL_OP_GET_STATS,
+ error = ixlv_send_pf_msg(sc, I40E_VIRTCHNL_OP_GET_STATS,
(u8 *)&vqs, sizeof(vqs));
+#ifdef IXL_DEBUG
+ if (error)
+ device_printf(sc->dev, "Error sending stats request to PF: %d\n", error);
+#endif
}
/*
diff --git a/sys/dev/sfxge/common/efsys.h b/sys/dev/sfxge/common/efsys.h
index 705d060..f14e69b 100644
--- a/sys/dev/sfxge/common/efsys.h
+++ b/sys/dev/sfxge/common/efsys.h
@@ -669,7 +669,7 @@ typedef struct efsys_bar_s {
uint32_t, (_eqp)->eq_u32[1], \
uint32_t, (_eqp)->eq_u32[0]); \
\
- mtx_unlock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_UNLOCK(_esbp); \
_NOTE(CONSTANTCONDITION) \
} while (B_FALSE)
@@ -681,7 +681,7 @@ typedef struct efsys_bar_s {
\
_NOTE(CONSTANTCONDITION) \
if (_lock) \
- mtx_lock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_LOCK(_esbp); \
\
(_eop)->eo_u64[0] = bus_space_read_8((_esbp)->esb_tag, \
(_esbp)->esb_handle, (_offset)); \
@@ -696,7 +696,7 @@ typedef struct efsys_bar_s {
\
_NOTE(CONSTANTCONDITION) \
if (_lock) \
- mtx_unlock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_UNLOCK(_esbp); \
_NOTE(CONSTANTCONDITION) \
} while (B_FALSE)
@@ -707,7 +707,7 @@ typedef struct efsys_bar_s {
KASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)), \
("not power of 2 aligned")); \
\
- mtx_lock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_LOCK(_esbp); \
\
(_eqp)->eq_u32[0] = bus_space_read_4((_esbp)->esb_tag, \
(_esbp)->esb_handle, (_offset)); \
@@ -762,7 +762,7 @@ typedef struct efsys_bar_s {
\
_NOTE(CONSTANTCONDITION) \
if (_lock) \
- SFXGE_BAR_LOCK(_esbp); \
+ SFXGE_BAR_LOCK(_esbp); \
\
EFSYS_PROBE2(bar_writed, unsigned int, (_offset), \
uint32_t, (_edp)->ed_u32[0]); \
@@ -772,7 +772,7 @@ typedef struct efsys_bar_s {
\
_NOTE(CONSTANTCONDITION) \
if (_lock) \
- SFXGE_BAR_UNLOCK(_esbp); \
+ SFXGE_BAR_UNLOCK(_esbp); \
_NOTE(CONSTANTCONDITION) \
} while (B_FALSE)
@@ -792,7 +792,7 @@ typedef struct efsys_bar_s {
bus_space_write_8((_esbp)->esb_tag, (_esbp)->esb_handle,\
(_offset), (_eqp)->eq_u64[0]); \
\
- mtx_unlock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_UNLOCK(_esbp); \
_NOTE(CONSTANTCONDITION) \
} while (B_FALSE)
#else
@@ -802,7 +802,7 @@ typedef struct efsys_bar_s {
KASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)), \
("not power of 2 aligned")); \
\
- mtx_lock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_LOCK(_esbp); \
\
EFSYS_PROBE3(bar_writeq, unsigned int, (_offset), \
uint32_t, (_eqp)->eq_u32[1], \
@@ -842,7 +842,7 @@ typedef struct efsys_bar_s {
\
_NOTE(CONSTANTCONDITION) \
if (_lock) \
- mtx_unlock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_UNLOCK(_esbp); \
_NOTE(CONSTANTCONDITION) \
} while (B_FALSE)
@@ -855,7 +855,7 @@ typedef struct efsys_bar_s {
\
_NOTE(CONSTANTCONDITION) \
if (_lock) \
- mtx_lock(&((_esbp)->esb_lock)); \
+ SFXGE_BAR_LOCK(_esbp); \
\
EFSYS_PROBE5(bar_writeo, unsigned int, (_offset), \
uint32_t, (_eop)->eo_u32[3], \
diff --git a/sys/dev/sfxge/common/efx.h b/sys/dev/sfxge/common/efx.h
index 7693de4..51e13f4 100644
--- a/sys/dev/sfxge/common/efx.h
+++ b/sys/dev/sfxge/common/efx.h
@@ -459,7 +459,7 @@ efx_mon_init(
#define EFX_MON_STATS_SIZE 0x100
-/* START MKCONFIG GENERATED MonitorHeaderStatsBlock 16a14e61aa4f8d80 */
+/* START MKCONFIG GENERATED MonitorHeaderStatsBlock 58706a378332aeee */
typedef enum efx_mon_stat_e {
EFX_MON_STAT_2_5V,
EFX_MON_STAT_VCCP1,
@@ -477,6 +477,20 @@ typedef enum efx_mon_stat_e {
EFX_MON_STAT_1_2V,
EFX_MON_STAT_1_8V,
EFX_MON_STAT_3_3V,
+ EFX_MON_STAT_1_2VA,
+ EFX_MON_STAT_VREF,
+ EFX_MON_STAT_VAOE,
+ EFX_MON_STAT_AOE_TEMP,
+ EFX_MON_STAT_PSU_AOE_TEMP,
+ EFX_MON_STAT_PSU_TEMP,
+ EFX_MON_STAT_FAN0,
+ EFX_MON_STAT_FAN1,
+ EFX_MON_STAT_FAN2,
+ EFX_MON_STAT_FAN3,
+ EFX_MON_STAT_FAN4,
+ EFX_MON_STAT_VAOE_IN,
+ EFX_MON_STAT_IAOE,
+ EFX_MON_STAT_IAOE_IN,
EFX_MON_NSTATS
} efx_mon_stat_t;
@@ -861,6 +875,7 @@ efx_phy_bist_stop(
#define EFX_FEATURE_MCDI 0x00000020
#define EFX_FEATURE_LOOKAHEAD_SPLIT 0x00000040
#define EFX_FEATURE_MAC_HEADER_FILTERS 0x00000080
+#define EFX_FEATURE_TURBO 0x00000100
typedef struct efx_nic_cfg_s {
uint32_t enc_board_type;
@@ -881,6 +896,7 @@ typedef struct efx_nic_cfg_s {
uint32_t enc_rxq_limit;
uint32_t enc_buftbl_limit;
uint32_t enc_evq_moderation_max;
+ uint32_t enc_clk_mult;
#if EFSYS_OPT_LOOPBACK
uint32_t enc_loopback_types[EFX_LINK_NMODES];
#endif /* EFSYS_OPT_LOOPBACK */
@@ -1598,14 +1614,15 @@ efx_rx_scale_toeplitz_ipv6_key_set(
#endif /* EFSYS_OPT_RX_SCALE */
-#define EFX_RXQ_MAXNDESCS 4096
-#define EFX_RXQ_MINNDESCS 512
+#define EFX_RXQ_MAXNDESCS 4096
+#define EFX_RXQ_MINNDESCS 512
-#define EFX_RXQ_NDESCS_MASK EFX_MASK(EFX_RXQ_MAXNDESCS, EFX_RXQ_MINNDESCS)
+#define EFX_RXQ_NDESCS_MASK EFX_MASK(EFX_RXQ_MAXNDESCS, EFX_RXQ_MINNDESCS)
-#define EFX_RXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t))
-#define EFX_RXQ_NBUFS(_ndescs) (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
-#define EFX_RXQ_LIMIT(_ndescs) ((_ndescs) - 16)
+#define EFX_RXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t))
+#define EFX_RXQ_NBUFS(_ndescs) (EFX_RXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
+#define EFX_RXQ_LIMIT(_ndescs) ((_ndescs) - 16)
+#define EFX_RXQ_DC_NDESCS(_dcsize) (8 << _dcsize)
typedef enum efx_rxq_type_e {
EFX_RXQ_TYPE_DEFAULT,
@@ -1684,14 +1701,15 @@ extern void
efx_tx_fini(
__in efx_nic_t *enp);
-#define EFX_TXQ_MAXNDESCS 4096
-#define EFX_TXQ_MINNDESCS 512
+#define EFX_TXQ_MAXNDESCS 4096
+#define EFX_TXQ_MINNDESCS 512
-#define EFX_TXQ_NDESCS_MASK EFX_MASK(EFX_TXQ_MAXNDESCS, EFX_TXQ_MINNDESCS)
+#define EFX_TXQ_NDESCS_MASK EFX_MASK(EFX_TXQ_MAXNDESCS, EFX_TXQ_MINNDESCS)
-#define EFX_TXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t))
-#define EFX_TXQ_NBUFS(_ndescs) (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
-#define EFX_TXQ_LIMIT(_ndescs) ((_ndescs) - 16)
+#define EFX_TXQ_SIZE(_ndescs) ((_ndescs) * sizeof (efx_qword_t))
+#define EFX_TXQ_NBUFS(_ndescs) (EFX_TXQ_SIZE(_ndescs) / EFX_BUF_SIZE)
+#define EFX_TXQ_LIMIT(_ndescs) ((_ndescs) - 16)
+#define EFX_TXQ_DC_NDESCS(_dcsize) (8 << _dcsize)
extern __checkReturn int
efx_tx_qcreate(
diff --git a/sys/dev/sfxge/common/efx_ev.c b/sys/dev/sfxge/common/efx_ev.c
index 27ecd41..feed316 100644
--- a/sys/dev/sfxge/common/efx_ev.c
+++ b/sys/dev/sfxge/common/efx_ev.c
@@ -567,6 +567,12 @@ efx_ev_mcdi(
if (enp->en_family != EFX_FAMILY_SIENA)
goto out;
+ EFSYS_ASSERT(eecp->eec_link_change != NULL);
+ EFSYS_ASSERT(eecp->eec_exception != NULL);
+#if EFSYS_OPT_MON_STATS
+ EFSYS_ASSERT(eecp->eec_monitor != NULL);
+#endif
+
EFX_EV_QSTAT_INCR(eep, EV_MCDI_RESPONSE);
code = EFX_QWORD_FIELD(*eqp, MCDI_EVENT_CODE);
@@ -648,7 +654,7 @@ out:
return (should_abort);
}
-#endif /* EFSYS_OPT_SIENA */
+#endif /* EFSYS_OPT_MCDI */
__checkReturn int
efx_ev_qprime(
@@ -844,13 +850,14 @@ efx_ev_qmoderate(
__in unsigned int us)
{
efx_nic_t *enp = eep->ee_enp;
+ efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
unsigned int locked;
efx_dword_t dword;
int rc;
EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
- if (us > enp->en_nic_cfg.enc_evq_moderation_max) {
+ if (us > encp->enc_evq_moderation_max) {
rc = EINVAL;
goto fail1;
}
@@ -869,21 +876,20 @@ efx_ev_qmoderate(
uint32_t timer_val;
/* Calculate the timer value in quanta */
- us -= (us % EFX_EV_TIMER_QUANTUM);
- if (us < EFX_EV_TIMER_QUANTUM)
- us = EFX_EV_TIMER_QUANTUM;
-
- timer_val = us / EFX_EV_TIMER_QUANTUM;
+ timer_val = us * encp->enc_clk_mult / EFX_EV_TIMER_QUANTUM;
/* Moderation value is base 0 so we need to deduct 1 */
+ if (timer_val > 0)
+ timer_val--;
+
if (enp->en_family == EFX_FAMILY_FALCON)
EFX_POPULATE_DWORD_2(dword,
FRF_AB_TC_TIMER_MODE, FFE_AB_TIMER_MODE_INT_HLDOFF,
- FRF_AB_TIMER_VAL, timer_val - 1);
+ FRF_AB_TIMER_VAL, timer_val);
else
EFX_POPULATE_DWORD_2(dword,
FRF_CZ_TC_TIMER_MODE, FFE_CZ_TIMER_MODE_INT_HLDOFF,
- FRF_CZ_TC_TIMER_VAL, timer_val - 1);
+ FRF_CZ_TC_TIMER_VAL, timer_val);
}
locked = (eep->ee_index == 0) ? 1 : 0;
@@ -964,7 +970,7 @@ efx_ev_qcreate(
eep->ee_handler[FSE_AZ_EV_CODE_DRV_GEN_EV] = efx_ev_drv_gen;
#if EFSYS_OPT_MCDI
eep->ee_handler[FSE_AZ_EV_CODE_MCDI_EVRESPONSE] = efx_ev_mcdi;
-#endif /* EFSYS_OPT_SIENA */
+#endif /* EFSYS_OPT_MCDI */
/* Set up the new event queue */
if (enp->en_family != EFX_FAMILY_FALCON) {
diff --git a/sys/dev/sfxge/common/efx_filter.c b/sys/dev/sfxge/common/efx_filter.c
index fa17ae3..e8455db 100644
--- a/sys/dev/sfxge/common/efx_filter.c
+++ b/sys/dev/sfxge/common/efx_filter.c
@@ -412,7 +412,7 @@ efx_filter_search(
__in uint32_t key,
__in boolean_t for_insert,
__out int *filter_index,
- __out int *depth_required)
+ __out unsigned int *depth_required)
{
unsigned hash, incr, filter_idx, depth;
@@ -528,7 +528,8 @@ efx_filter_remove_filter(
efx_filter_tbl_t *eftp = &efp->ef_tbl[tbl_id];
efx_filter_spec_t *saved_spec;
efx_oword_t filter;
- int filter_idx, depth;
+ int filter_idx;
+ unsigned int depth;
int state;
uint32_t key;
int rc;
@@ -561,7 +562,7 @@ efx_filter_remove_index(
__in int index)
{
efx_filter_t *efp = &enp->en_filter;
- enum efx_filter_tbl_id tbl_id = efx_filter_tbl_id(type);
+ efx_filter_tbl_id_t tbl_id = efx_filter_tbl_id(type);
efx_filter_tbl_t *eftp = &efp->ef_tbl[tbl_id];
int state;
@@ -721,7 +722,7 @@ efx_filter_init(
eftp->eft_spec);
if (!eftp->eft_spec) {
rc = ENOMEM;
- goto fail2;
+ goto fail3;
}
memset(eftp->eft_spec, 0, eftp->eft_size * sizeof(*eftp->eft_spec));
}
@@ -729,6 +730,9 @@ efx_filter_init(
return (0);
+fail3:
+ EFSYS_PROBE(fail3);
+
fail2:
EFSYS_PROBE(fail2);
efx_filter_fini(enp);
@@ -755,12 +759,17 @@ efx_filter_fini(
EFX_STATIC_ASSERT(sizeof(eftp->eft_bitmap[0]) == sizeof(uint32_t));
bitmap_size = (eftp->eft_size + (sizeof(uint32_t) * 8) - 1) / 8;
- EFSYS_KMEM_FREE(enp->en_esip, bitmap_size, eftp->eft_bitmap);
- eftp->eft_bitmap = NULL;
+ if (eftp->eft_bitmap != NULL) {
+ EFSYS_KMEM_FREE(enp->en_esip, bitmap_size,
+ eftp->eft_bitmap);
+ eftp->eft_bitmap = NULL;
+ }
- EFSYS_KMEM_FREE(enp->en_esip, eftp->eft_size * sizeof(*eftp->eft_spec),
- eftp->eft_spec);
- eftp->eft_spec = NULL;
+ if (eftp->eft_spec != NULL) {
+ EFSYS_KMEM_FREE(enp->en_esip, eftp->eft_size *
+ sizeof(*eftp->eft_spec), eftp->eft_spec);
+ eftp->eft_spec = NULL;
+ }
}
enp->en_mod_flags &= ~EFX_MOD_FILTER;
diff --git a/sys/dev/sfxge/common/efx_impl.h b/sys/dev/sfxge/common/efx_impl.h
index 31681f2..6202276 100644
--- a/sys/dev/sfxge/common/efx_impl.h
+++ b/sys/dev/sfxge/common/efx_impl.h
@@ -200,8 +200,18 @@ typedef struct efx_nic_ops_s {
void (*eno_unprobe)(efx_nic_t *);
} efx_nic_ops_t;
-#define EFX_TXQ_LIMIT_TARGET 259
-#define EFX_RXQ_LIMIT_TARGET 768
+#ifndef EFX_TXQ_LIMIT_TARGET
+# define EFX_TXQ_LIMIT_TARGET 259
+#endif
+#ifndef EFX_RXQ_LIMIT_TARGET
+# define EFX_RXQ_LIMIT_TARGET 768
+#endif
+#ifndef EFX_TXQ_DC_SIZE
+#define EFX_TXQ_DC_SIZE 1 /* 16 descriptors */
+#endif
+#ifndef EFX_RXQ_DC_SIZE
+#define EFX_RXQ_DC_SIZE 3 /* 64 descriptors */
+#endif
#if EFSYS_OPT_FILTER
diff --git a/sys/dev/sfxge/common/efx_mcdi.c b/sys/dev/sfxge/common/efx_mcdi.c
index 5853b06..5826c8a 100644
--- a/sys/dev/sfxge/common/efx_mcdi.c
+++ b/sys/dev/sfxge/common/efx_mcdi.c
@@ -35,15 +35,6 @@ __FBSDID("$FreeBSD$");
#if EFSYS_OPT_MCDI
-/* Shared memory layout */
-
-#define MCDI_P1_DBL_OFST 0x0
-#define MCDI_P2_DBL_OFST 0x1
-#define MCDI_P1_PDU_OFST 0x2
-#define MCDI_P2_PDU_OFST 0x42
-#define MCDI_P1_REBOOT_OFST 0x1fe
-#define MCDI_P2_REBOOT_OFST 0x1ff
-
/*
* A reboot/assertion causes the MCDI status word to be set after the
* command word is set or a REBOOT event is sent. If we notice a reboot
@@ -72,12 +63,12 @@ efx_mcdi_request_start(
switch (emip->emi_port) {
case 1:
- pdur = MCDI_P1_PDU_OFST;
- dbr = MCDI_P1_DBL_OFST;
+ pdur = MC_SMEM_P0_PDU_OFST >> 2;
+ dbr = MC_SMEM_P0_DOORBELL_OFST >> 2;
break;
case 2:
- pdur = MCDI_P2_PDU_OFST;
- dbr = MCDI_P2_DBL_OFST;
+ pdur = MC_SMEM_P1_PDU_OFST >> 2;
+ dbr = MC_SMEM_P1_DOORBELL_OFST >> 2;
break;
default:
EFSYS_ASSERT(0);
@@ -140,7 +131,9 @@ efx_mcdi_request_copyout(
unsigned int pdur;
efx_dword_t data;
- pdur = (emip->emi_port == 1) ? MCDI_P1_PDU_OFST : MCDI_P2_PDU_OFST;
+ pdur = (emip->emi_port == 1)
+ ? MC_SMEM_P0_PDU_OFST >> 2
+ : MC_SMEM_P1_PDU_OFST >> 2;
/* Copy payload out if caller supplied buffer */
if (emrp->emr_out_buf != NULL) {
@@ -227,8 +220,8 @@ efx_mcdi_poll_reboot(
EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2);
rebootr = ((emip->emi_port == 1)
- ? MCDI_P1_REBOOT_OFST
- : MCDI_P2_REBOOT_OFST);
+ ? MC_SMEM_P0_STATUS_OFST >> 2
+ : MC_SMEM_P1_STATUS_OFST >> 2);
EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, rebootr, &dword, B_FALSE);
value = EFX_DWORD_FIELD(dword, EFX_DWORD_0);
@@ -281,7 +274,9 @@ efx_mcdi_request_poll(
}
EFSYS_ASSERT(emip->emi_port == 1 || emip->emi_port == 2);
- pdur = (emip->emi_port == 1) ? MCDI_P1_PDU_OFST : MCDI_P2_PDU_OFST;
+ pdur = (emip->emi_port == 1)
+ ? MC_SMEM_P0_PDU_OFST >> 2
+ : MC_SMEM_P1_PDU_OFST >> 2;
/* Read the command header */
EFX_BAR_TBL_READD(enp, FR_CZ_MC_TREG_SMEM, pdur, &dword, B_FALSE);
@@ -532,7 +527,7 @@ efx_mcdi_version(
version:
/* The bootrom doesn't understand BOOT_STATUS */
- if (build == MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM) {
+ if (build == MC_CMD_GET_VERSION_OUT_FIRMWARE_SIENA_BOOTROM) {
status = EFX_MCDI_BOOT_ROM;
goto out;
}
diff --git a/sys/dev/sfxge/common/efx_mcdi.h b/sys/dev/sfxge/common/efx_mcdi.h
index ad054b3..b115746 100644
--- a/sys/dev/sfxge/common/efx_mcdi.h
+++ b/sys/dev/sfxge/common/efx_mcdi.h
@@ -233,6 +233,9 @@ efx_mcdi_version(
#define MCDI_EV_FIELD(_eqp, _field) \
EFX_QWORD_FIELD(*_eqp, MCDI_EVENT_ ## _field)
+#define MCDI_CMD_DWORD_FIELD(_edp, _field) \
+ EFX_DWORD_FIELD(*_edp, MC_CMD_ ## _field)
+
#ifdef __cplusplus
}
#endif
diff --git a/sys/dev/sfxge/common/efx_mon.c b/sys/dev/sfxge/common/efx_mon.c
index 5d397c3..dc2e256 100644
--- a/sys/dev/sfxge/common/efx_mon.c
+++ b/sys/dev/sfxge/common/efx_mon.c
@@ -195,7 +195,7 @@ fail1:
#if EFSYS_OPT_NAMES
-/* START MKCONFIG GENERATED MonitorStatNamesBlock 08518fd1fb4e2612 */
+/* START MKCONFIG GENERATED MonitorStatNamesBlock 89ff37f1d74ad8b3 */
static const char __cs * __cs __mon_stat_name[] = {
"value_2_5v",
"value_vccp1",
@@ -213,6 +213,20 @@ static const char __cs * __cs __mon_stat_name[] = {
"1_2v",
"1_8v",
"3_3v",
+ "1_2va",
+ "vref",
+ "vaoe",
+ "aoe_temperature",
+ "psu_aoe_temperature",
+ "psu_temperature",
+ "fan0",
+ "fan1",
+ "fan2",
+ "fan3",
+ "fan4",
+ "vaoe_in",
+ "iaoe",
+ "iaoe_in",
};
/* END MKCONFIG GENERATED MonitorStatNamesBlock */
diff --git a/sys/dev/sfxge/common/efx_nic.c b/sys/dev/sfxge/common/efx_nic.c
index 2bb55d1..b0ba58c 100644
--- a/sys/dev/sfxge/common/efx_nic.c
+++ b/sys/dev/sfxge/common/efx_nic.c
@@ -249,10 +249,13 @@ efx_nic_create(
#if EFSYS_OPT_SIENA
case EFX_FAMILY_SIENA:
enp->en_enop = (efx_nic_ops_t *)&__efx_nic_siena_ops;
- enp->en_features = EFX_FEATURE_IPV6 |
+ enp->en_features =
+ EFX_FEATURE_IPV6 |
EFX_FEATURE_LFSR_HASH_INSERT |
- EFX_FEATURE_LINK_EVENTS | EFX_FEATURE_PERIODIC_MAC_STATS |
- EFX_FEATURE_WOL | EFX_FEATURE_MCDI |
+ EFX_FEATURE_LINK_EVENTS |
+ EFX_FEATURE_PERIODIC_MAC_STATS |
+ EFX_FEATURE_WOL |
+ EFX_FEATURE_MCDI |
EFX_FEATURE_LOOKAHEAD_SPLIT |
EFX_FEATURE_MAC_HEADER_FILTERS;
break;
diff --git a/sys/dev/sfxge/common/efx_phy.c b/sys/dev/sfxge/common/efx_phy.c
index 0300e04..bb34ea7 100644
--- a/sys/dev/sfxge/common/efx_phy.c
+++ b/sys/dev/sfxge/common/efx_phy.c
@@ -427,6 +427,7 @@ efx_phy_adv_cap_set(
{
efx_port_t *epp = &(enp->en_port);
efx_phy_ops_t *epop = epp->ep_epop;
+ uint32_t old_mask;
int rc;
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
@@ -440,6 +441,7 @@ efx_phy_adv_cap_set(
if (epp->ep_adv_cap_mask == mask)
goto done;
+ old_mask = epp->ep_adv_cap_mask;
epp->ep_adv_cap_mask = mask;
if ((rc = epop->epo_reconfigure(enp)) != 0)
@@ -450,6 +452,17 @@ done:
fail2:
EFSYS_PROBE(fail2);
+
+ epp->ep_adv_cap_mask = old_mask;
+ /* Reconfigure for robustness */
+ if (epop->epo_reconfigure(enp) != 0) {
+ /*
+ * We may have an inconsistent view of our advertised speed
+ * capabilities.
+ */
+ EFSYS_ASSERT(0);
+ }
+
fail1:
EFSYS_PROBE1(fail1, int, rc);
diff --git a/sys/dev/sfxge/common/efx_regs_ef10.h b/sys/dev/sfxge/common/efx_regs_ef10.h
index ef62b58..c4a6d0e 100644
--- a/sys/dev/sfxge/common/efx_regs_ef10.h
+++ b/sys/dev/sfxge/common/efx_regs_ef10.h
@@ -1732,8 +1732,8 @@ extern "C" {
#define ESF_DZ_RX_U_QST1_SPARE_WIDTH 12
#define ESF_DZ_RX_U_SOFT16_B0R3_0_LBN 48
#define ESF_DZ_RX_U_SOFT16_B0R3_0_WIDTH 16
-#define ESF_DZ_RX_U_PKT_EDIT_LBN 51
-#define ESF_DZ_RX_U_PKT_EDIT_WIDTH 1
+#define ESF_DZ_RX_U_TIMESTAMP_LBN 51
+#define ESF_DZ_RX_U_TIMESTAMP_WIDTH 1
#define ESF_DZ_RX_U_DOORBELL_ENABLED_LBN 50
#define ESF_DZ_RX_U_DOORBELL_ENABLED_WIDTH 1
#define ESF_DZ_RX_U_WORK_PENDING_LBN 49
@@ -2677,6 +2677,138 @@ extern "C" {
#define ESF_DZ_B2T_CPL_RSP_CPL_ADRS_WIDTH 7
+
+/* Enum DPCPU_INSTR_BRTYPE */
+#define ESE_DZ_BNEZAL 19
+#define ESE_DZ_BEQZAL 18
+#define ESE_DZ_BGEZAL 17
+#define ESE_DZ_BLTZAL 16
+#define ESE_DZ_BNEZ 3
+#define ESE_DZ_BEQZ 2
+#define ESE_DZ_BGEZ 1
+#define ESE_DZ_BLTZ 0
+
+/* Enum DPCPU_INSTR_FUNCT */
+#define ESE_DZ_MASKMOD 44
+#define ESE_DZ_SLTU 43
+#define ESE_DZ_SLT 42
+#define ESE_DZ_INCMOD 40
+#define ESE_DZ_NOR 39
+#define ESE_DZ_XOR 38
+#define ESE_DZ_OR 37
+#define ESE_DZ_AND 36
+#define ESE_DZ_SUBU 35
+#define ESE_DZ_SUB 34
+#define ESE_DZ_ADDU 33
+#define ESE_DZ_ADD 32
+#define ESE_DZ_MULT 25
+#define ESE_DZ_MFLO 18
+#define ESE_DZ_MFHI 16
+#define ESE_DZ_JALR 9
+#define ESE_DZ_JR 8
+#define ESE_DZ_SRAV 7
+#define ESE_DZ_SRLV 6
+#define ESE_DZ_SLLV 4
+#define ESE_DZ_SRA 3
+#define ESE_DZ_SRL 2
+#define ESE_DZ_SLL 0
+
+/* Enum DPCPU_INSTR_OP */
+#define ESE_DZ_LM_MSG 49
+#define ESE_DZ_MSG 48
+#define ESE_DZ_SHA 43
+#define ESE_DZ_SBA 42
+#define ESE_DZ_SH 41
+#define ESE_DZ_SB 40
+#define ESE_DZ_LHUA 39
+#define ESE_DZ_LBUA 38
+#define ESE_DZ_LHU 37
+#define ESE_DZ_LBU 36
+#define ESE_DZ_LHA 35
+#define ESE_DZ_LBA 34
+#define ESE_DZ_LH 33
+#define ESE_DZ_LB 32
+#define ESE_DZ_BGTU 31
+#define ESE_DZ_BLEU 30
+#define ESE_DZ_MODI 28
+#define ESE_DZ_NEGU 27
+#define ESE_DZ_NEG 26
+#define ESE_DZ_LI 25
+#define ESE_DZ_INCMODI 24
+#define ESE_DZ_BGT 23
+#define ESE_DZ_BLE 22
+#define ESE_DZ_BBS 21
+#define ESE_DZ_BBC 20
+#define ESE_DZ_JAL_EVT 19
+#define ESE_DZ_J_EVT 18
+#define ESE_DZ_HALT 16
+#define ESE_DZ_NORI 15
+#define ESE_DZ_XORI 14
+#define ESE_DZ_ORI 13
+#define ESE_DZ_ANDI 12
+#define ESE_DZ_SLTIU 11
+#define ESE_DZ_SLTI 10
+#define ESE_DZ_ADDIU 9
+#define ESE_DZ_ADDI 8
+#define ESE_DZ_BGTZ 7
+#define ESE_DZ_BLEZ 6
+#define ESE_DZ_BNE 5
+#define ESE_DZ_BEQ 4
+#define ESE_DZ_JAL 3
+#define ESE_DZ_J 2
+#define ESE_DZ_BRANCH 1
+#define ESE_DZ_REG2REG 0
+
+/* Enum DPCPU_MSG_DIR */
+#define ESE_DPCPU_MSG_DZ_OUTB 0x1
+#define ESE_DPCPU_MSG_DZ_INB 0x0
+
+/* Enum DPCPU_PDBUS_OP */
+#define ESE_DPCPU_PDBUS_DZ_RD 0x1
+#define ESE_DPCPU_PDBUS_DZ_WR 0x0
+
+/* Enum INI_OP */
+#define ESE_DZ_RD_COMPL 0x3
+#define ESE_DZ_NOP 0x2
+#define ESE_DZ_WR 0x1
+#define ESE_DZ_RD 0x0
+
+/* Enum INT_OP */
+#define ESE_DZ_LEGACY 0x2
+#define ESE_DZ_MSI 0x1
+#define ESE_DZ_MSIX 0x0
+
+/* Enum PKT_STRM_CTL */
+#define ESE_DZ_EOP_TRUNC 0x3
+#define ESE_DZ_EOP_CRC_ERR 0x2
+#define ESE_DZ_EOP 0x1
+#define ESE_DZ_NOOP 0x0
+
+/* Enum PM_EPI_PKT_MARKER */
+#define ESE_DZ_PM_EPI_LST 0x3
+#define ESE_DZ_PM_EPI_OBL 0x2
+#define ESE_DZ_PM_EPI_TBL 0x1
+#define ESE_DZ_PM_EPI_MDL 0x0
+
+/* Enum PM_IPI_TO_PM_MM_COMMAND */
+#define ESE_DZ_FREE_CHAIN 0x3
+#define ESE_DZ_FREE_BUFFER 0x2
+#define ESE_DZ_ADD_BUFFER 0x1
+#define ESE_DZ_PM_MM_NOOP 0x0
+
+/* Enum PM_MA_TO_PM_EPI_COMMAND */
+#define ESE_DZ_FROM_PORT_D 0x4
+#define ESE_DZ_FROM_PORT_C 0x3
+#define ESE_DZ_FROM_PORT_B 0x2
+#define ESE_DZ_FROM_PORT_A 0x1
+#define ESE_DZ_PM_EPI_NOOP 0x0
+
+/* Enum PM_MA_TO_PM_IPI_COMMAND */
+#define ESE_DZ_TO_PORT_D 0x4
+#define ESE_DZ_TO_PORT_C 0x3
+#define ESE_DZ_TO_PORT_B 0x2
+#define ESE_DZ_TO_PORT_A 0x1
+#define ESE_DZ_PM_IPI_NOOP 0x0
#ifdef __cplusplus
}
#endif
diff --git a/sys/dev/sfxge/common/efx_regs_mcdi.h b/sys/dev/sfxge/common/efx_regs_mcdi.h
index 9ee2513..9016ca9 100644
--- a/sys/dev/sfxge/common/efx_regs_mcdi.h
+++ b/sys/dev/sfxge/common/efx_regs_mcdi.h
@@ -40,6 +40,18 @@
/* The Scheduler has started. */
#define MC_FW_STATE_SCHED (8)
+/* Siena MC shared memmory offsets */
+/* The 'doorbell' addresses are hard-wired to alert the MC when written */
+#define MC_SMEM_P0_DOORBELL_OFST 0x000
+#define MC_SMEM_P1_DOORBELL_OFST 0x004
+/* The rest of these are firmware-defined */
+#define MC_SMEM_P0_PDU_OFST 0x008
+#define MC_SMEM_P1_PDU_OFST 0x108
+#define MC_SMEM_PDU_LEN 0x100
+#define MC_SMEM_P0_PTP_TIME_OFST 0x7f0
+#define MC_SMEM_P0_STATUS_OFST 0x7f8
+#define MC_SMEM_P1_STATUS_OFST 0x7fc
+
/* Values to be written to the per-port status dword in shared
* memory on reboot and assert */
#define MC_STATUS_DWORD_REBOOT (0xb007b007)
@@ -58,10 +70,7 @@
/* Unused commands: 0x23, 0x27, 0x30, 0x31 */
-/* Unused commands: 0x23, 0x27, 0x30, 0x31 */
-
-/**
- * MCDI version 1
+/* MCDI version 1
*
* Each MCDI request starts with an MCDI_HEADER, which is a 32byte
* structure, filled in by the client.
@@ -113,10 +122,10 @@
#define MCDI_HEADER_XFLAGS_EVREQ 0x01
/* Maximum number of payload bytes */
-#if MCDI_PCOL_VERSION == 1
-#define MCDI_CTL_SDU_LEN_MAX 0xfc
-#elif MCDI_PCOL_VERSION == 2
+#ifdef WITH_MCDI_V2
#define MCDI_CTL_SDU_LEN_MAX 0x400
+#else
+#define MCDI_CTL_SDU_LEN_MAX 0xfc
#endif
/* The MC can generate events for two reasons:
@@ -133,7 +142,7 @@
*
* If Code==CMDDONE, then the fields are further interpreted as:
*
- * - LEVEL==INFO Command succeded
+ * - LEVEL==INFO Command succeeded
* - LEVEL==ERR Command failed
*
* 0 8 16 24 32
@@ -293,6 +302,27 @@
#define MCDI_EVENT_TX_ERR_INFO_WIDTH 16
#define MCDI_EVENT_TX_FLUSH_TXQ_LBN 0
#define MCDI_EVENT_TX_FLUSH_TXQ_WIDTH 12
+#define MCDI_EVENT_PTP_ERR_TYPE_LBN 0
+#define MCDI_EVENT_PTP_ERR_TYPE_WIDTH 8
+#define MCDI_EVENT_PTP_ERR_PLL_LOST 0x1 /* enum */
+#define MCDI_EVENT_PTP_ERR_FILTER 0x2 /* enum */
+#define MCDI_EVENT_PTP_ERR_FIFO 0x3 /* enum */
+#define MCDI_EVENT_PTP_ERR_QUEUE 0x4 /* enum */
+#define MCDI_EVENT_AOE_ERR_TYPE_LBN 0
+#define MCDI_EVENT_AOE_ERR_TYPE_WIDTH 8
+#define MCDI_EVENT_AOE_NO_LOAD 0x1 /* enum */
+#define MCDI_EVENT_AOE_FC_ASSERT 0x2 /* enum */
+#define MCDI_EVENT_AOE_FC_WATCHDOG 0x3 /* enum */
+#define MCDI_EVENT_AOE_FC_NO_START 0x4 /* enum */
+#define MCDI_EVENT_AOE_FAULT 0x5 /* enum */
+#define MCDI_EVENT_AOE_CPLD_REPROGRAMMED 0x6 /* enum */
+#define MCDI_EVENT_AOE_LOAD 0x7 /* enum */
+#define MCDI_EVENT_AOE_DMA 0x8 /* enum */
+#define MCDI_EVENT_AOE_BYTEBLASTER 0x9 /* enum */
+#define MCDI_EVENT_AOE_DDR_ECC_STATUS 0xa /* enum */
+#define MCDI_EVENT_AOE_PTP_STATUS 0xb /* enum */
+#define MCDI_EVENT_AOE_ERR_DATA_LBN 8
+#define MCDI_EVENT_AOE_ERR_DATA_WIDTH 8
#define MCDI_EVENT_DATA_LBN 0
#define MCDI_EVENT_DATA_WIDTH 32
#define MCDI_EVENT_SRC_LBN 36
@@ -313,6 +343,12 @@
#define MCDI_EVENT_CODE_FLR 0xa /* enum */
#define MCDI_EVENT_CODE_TX_ERR 0xb /* enum */
#define MCDI_EVENT_CODE_TX_FLUSH 0xc /* enum */
+#define MCDI_EVENT_CODE_PTP_RX 0xd /* enum */
+#define MCDI_EVENT_CODE_PTP_FAULT 0xe /* enum */
+#define MCDI_EVENT_CODE_PTP_PPS 0xf /* enum */
+#define MCDI_EVENT_CODE_AOE 0x12 /* enum */
+#define MCDI_EVENT_CODE_VCAL_FAIL 0x13 /* enum */
+#define MCDI_EVENT_CODE_HW_PPS 0x14 /* enum */
#define MCDI_EVENT_CMDDONE_DATA_OFST 0
#define MCDI_EVENT_CMDDONE_DATA_LBN 0
#define MCDI_EVENT_CMDDONE_DATA_WIDTH 32
@@ -328,6 +364,94 @@
#define MCDI_EVENT_TX_ERR_DATA_OFST 0
#define MCDI_EVENT_TX_ERR_DATA_LBN 0
#define MCDI_EVENT_TX_ERR_DATA_WIDTH 32
+#define MCDI_EVENT_PTP_SECONDS_OFST 0
+#define MCDI_EVENT_PTP_SECONDS_LBN 0
+#define MCDI_EVENT_PTP_SECONDS_WIDTH 32
+#define MCDI_EVENT_PTP_NANOSECONDS_OFST 0
+#define MCDI_EVENT_PTP_NANOSECONDS_LBN 0
+#define MCDI_EVENT_PTP_NANOSECONDS_WIDTH 32
+#define MCDI_EVENT_PTP_UUID_OFST 0
+#define MCDI_EVENT_PTP_UUID_LBN 0
+#define MCDI_EVENT_PTP_UUID_WIDTH 32
+
+/* FCDI_EVENT structuredef */
+#define FCDI_EVENT_LEN 8
+#define FCDI_EVENT_CONT_LBN 32
+#define FCDI_EVENT_CONT_WIDTH 1
+#define FCDI_EVENT_LEVEL_LBN 33
+#define FCDI_EVENT_LEVEL_WIDTH 3
+#define FCDI_EVENT_LEVEL_INFO 0x0 /* enum */
+#define FCDI_EVENT_LEVEL_WARN 0x1 /* enum */
+#define FCDI_EVENT_LEVEL_ERR 0x2 /* enum */
+#define FCDI_EVENT_LEVEL_FATAL 0x3 /* enum */
+#define FCDI_EVENT_DATA_OFST 0
+#define FCDI_EVENT_LINK_STATE_STATUS_LBN 0
+#define FCDI_EVENT_LINK_STATE_STATUS_WIDTH 1
+#define FCDI_EVENT_LINK_DOWN 0x0 /* enum */
+#define FCDI_EVENT_LINK_UP 0x1 /* enum */
+#define FCDI_EVENT_DATA_LBN 0
+#define FCDI_EVENT_DATA_WIDTH 32
+#define FCDI_EVENT_SRC_LBN 36
+#define FCDI_EVENT_SRC_WIDTH 8
+#define FCDI_EVENT_EV_CODE_LBN 60
+#define FCDI_EVENT_EV_CODE_WIDTH 4
+#define FCDI_EVENT_CODE_LBN 44
+#define FCDI_EVENT_CODE_WIDTH 8
+#define FCDI_EVENT_CODE_REBOOT 0x1 /* enum */
+#define FCDI_EVENT_CODE_ASSERT 0x2 /* enum */
+#define FCDI_EVENT_CODE_DDR_TEST_RESULT 0x3 /* enum */
+#define FCDI_EVENT_CODE_LINK_STATE 0x4 /* enum */
+#define FCDI_EVENT_CODE_TIMED_READ 0x5 /* enum */
+#define FCDI_EVENT_CODE_PPS_IN 0x6 /* enum */
+#define FCDI_EVENT_CODE_PTP_TICK 0x7 /* enum */
+#define FCDI_EVENT_CODE_DDR_ECC_STATUS 0x8 /* enum */
+#define FCDI_EVENT_CODE_PTP_STATUS 0x9 /* enum */
+#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_OFST 0
+#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_LBN 0
+#define FCDI_EVENT_ASSERT_INSTR_ADDRESS_WIDTH 32
+#define FCDI_EVENT_ASSERT_TYPE_LBN 36
+#define FCDI_EVENT_ASSERT_TYPE_WIDTH 8
+#define FCDI_EVENT_DDR_TEST_RESULT_STATUS_CODE_LBN 36
+#define FCDI_EVENT_DDR_TEST_RESULT_STATUS_CODE_WIDTH 8
+#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_OFST 0
+#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_LBN 0
+#define FCDI_EVENT_DDR_TEST_RESULT_RESULT_WIDTH 32
+#define FCDI_EVENT_LINK_STATE_DATA_OFST 0
+#define FCDI_EVENT_LINK_STATE_DATA_LBN 0
+#define FCDI_EVENT_LINK_STATE_DATA_WIDTH 32
+#define FCDI_EVENT_PTP_STATE_OFST 0
+#define FCDI_EVENT_PTP_UNDEFINED 0x0 /* enum */
+#define FCDI_EVENT_PTP_SETUP_FAILED 0x1 /* enum */
+#define FCDI_EVENT_PTP_OPERATIONAL 0x2 /* enum */
+#define FCDI_EVENT_PTP_STATE_LBN 0
+#define FCDI_EVENT_PTP_STATE_WIDTH 32
+#define FCDI_EVENT_DDR_ECC_STATUS_BANK_ID_LBN 36
+#define FCDI_EVENT_DDR_ECC_STATUS_BANK_ID_WIDTH 8
+#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_OFST 0
+#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_LBN 0
+#define FCDI_EVENT_DDR_ECC_STATUS_STATUS_WIDTH 32
+
+/* FCDI_EXTENDED_EVENT_PPS structuredef */
+#define FCDI_EXTENDED_EVENT_PPS_LENMIN 16
+#define FCDI_EXTENDED_EVENT_PPS_LENMAX 248
+#define FCDI_EXTENDED_EVENT_PPS_LEN(num) (8+8*(num))
+#define FCDI_EXTENDED_EVENT_PPS_COUNT_OFST 0
+#define FCDI_EXTENDED_EVENT_PPS_COUNT_LBN 0
+#define FCDI_EXTENDED_EVENT_PPS_COUNT_WIDTH 32
+#define FCDI_EXTENDED_EVENT_PPS_SECONDS_OFST 8
+#define FCDI_EXTENDED_EVENT_PPS_SECONDS_LBN 64
+#define FCDI_EXTENDED_EVENT_PPS_SECONDS_WIDTH 32
+#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_OFST 12
+#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_LBN 96
+#define FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_WIDTH 32
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_OFST 8
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LEN 8
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LO_OFST 8
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_HI_OFST 12
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_MINNUM 1
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_MAXNUM 30
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_LBN 64
+#define FCDI_EXTENDED_EVENT_PPS_TIMESTAMPS_WIDTH 64
/***********************************/
@@ -478,6 +602,8 @@
#define MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0
#define MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff /* enum */
#define MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM 0xb0070000 /* enum */
+#define MC_CMD_GET_VERSION_OUT_FIRMWARE_SIENA_BOOTROM 0xb0070000 /* enum */
+#define MC_CMD_GET_VERSION_OUT_FIRMWARE_HUNT_BOOTROM 0xb0070001 /* enum */
/* MC_CMD_GET_VERSION_OUT msgresponse */
#define MC_CMD_GET_VERSION_OUT_LEN 32
@@ -494,6 +620,2059 @@
/***********************************/
+/* MC_CMD_FC
+ * Perform an FC operation
+ */
+#define MC_CMD_FC 0x9
+
+/* MC_CMD_FC_IN msgrequest */
+#define MC_CMD_FC_IN_LEN 4
+#define MC_CMD_FC_IN_OP_HDR_OFST 0
+#define MC_CMD_FC_IN_OP_LBN 0
+#define MC_CMD_FC_IN_OP_WIDTH 8
+#define MC_CMD_FC_OP_NULL 0x1 /* enum */
+#define MC_CMD_FC_OP_UNUSED 0x2 /* enum */
+#define MC_CMD_FC_OP_MAC 0x3 /* enum */
+#define MC_CMD_FC_OP_READ32 0x4 /* enum */
+#define MC_CMD_FC_OP_WRITE32 0x5 /* enum */
+#define MC_CMD_FC_OP_TRC_READ 0x6 /* enum */
+#define MC_CMD_FC_OP_TRC_WRITE 0x7 /* enum */
+#define MC_CMD_FC_OP_GET_VERSION 0x8 /* enum */
+#define MC_CMD_FC_OP_TRC_RX_READ 0x9 /* enum */
+#define MC_CMD_FC_OP_TRC_RX_WRITE 0xa /* enum */
+#define MC_CMD_FC_OP_SFP 0xb /* enum */
+#define MC_CMD_FC_OP_DDR_TEST 0xc /* enum */
+#define MC_CMD_FC_OP_GET_ASSERT 0xd /* enum */
+#define MC_CMD_FC_OP_FPGA_BUILD 0xe /* enum */
+#define MC_CMD_FC_OP_READ_MAP 0xf /* enum */
+#define MC_CMD_FC_OP_CAPABILITIES 0x10 /* enum */
+#define MC_CMD_FC_OP_GLOBAL_FLAGS 0x11 /* enum */
+#define MC_CMD_FC_OP_IO_REL 0x12 /* enum */
+#define MC_CMD_FC_OP_UHLINK 0x13 /* enum */
+#define MC_CMD_FC_OP_SET_LINK 0x14 /* enum */
+#define MC_CMD_FC_OP_LICENSE 0x15 /* enum */
+#define MC_CMD_FC_OP_STARTUP 0x16 /* enum */
+#define MC_CMD_FC_OP_DMA 0x17 /* enum */
+#define MC_CMD_FC_OP_TIMED_READ 0x18 /* enum */
+#define MC_CMD_FC_OP_LOG 0x19 /* enum */
+#define MC_CMD_FC_OP_CLOCK 0x1a /* enum */
+#define MC_CMD_FC_OP_DDR 0x1b /* enum */
+#define MC_CMD_FC_OP_TIMESTAMP 0x1c /* enum */
+#define MC_CMD_FC_OP_SPI 0x1d /* enum */
+#define MC_CMD_FC_OP_DIAG 0x1e /* enum */
+#define MC_CMD_FC_IN_PORT_EXT_OFST 0x0 /* enum */
+#define MC_CMD_FC_IN_PORT_INT_OFST 0x40 /* enum */
+
+/* MC_CMD_FC_IN_NULL msgrequest */
+#define MC_CMD_FC_IN_NULL_LEN 4
+#define MC_CMD_FC_IN_CMD_OFST 0
+
+/* MC_CMD_FC_IN_MAC msgrequest */
+#define MC_CMD_FC_IN_MAC_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_MAC_HEADER_OFST 4
+#define MC_CMD_FC_IN_MAC_OP_LBN 0
+#define MC_CMD_FC_IN_MAC_OP_WIDTH 8
+#define MC_CMD_FC_OP_MAC_OP_RECONFIGURE 0x1 /* enum */
+#define MC_CMD_FC_OP_MAC_OP_SET_LINK 0x2 /* enum */
+#define MC_CMD_FC_OP_MAC_OP_GET_STATS 0x3 /* enum */
+#define MC_CMD_FC_OP_MAC_OP_GET_RX_STATS 0x6 /* enum */
+#define MC_CMD_FC_OP_MAC_OP_GET_TX_STATS 0x7 /* enum */
+#define MC_CMD_FC_OP_MAC_OP_READ_STATUS 0x8 /* enum */
+#define MC_CMD_FC_IN_MAC_PORT_TYPE_LBN 8
+#define MC_CMD_FC_IN_MAC_PORT_TYPE_WIDTH 8
+#define MC_CMD_FC_PORT_EXT 0x0 /* enum */
+#define MC_CMD_FC_PORT_INT 0x1 /* enum */
+#define MC_CMD_FC_IN_MAC_PORT_IDX_LBN 16
+#define MC_CMD_FC_IN_MAC_PORT_IDX_WIDTH 8
+#define MC_CMD_FC_IN_MAC_CMD_FORMAT_LBN 24
+#define MC_CMD_FC_IN_MAC_CMD_FORMAT_WIDTH 8
+#define MC_CMD_FC_OP_MAC_CMD_FORMAT_DEFAULT 0x0 /* enum */
+#define MC_CMD_FC_OP_MAC_CMD_FORMAT_PORT_OVERRIDE 0x1 /* enum */
+
+/* MC_CMD_FC_IN_MAC_RECONFIGURE msgrequest */
+#define MC_CMD_FC_IN_MAC_RECONFIGURE_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_MAC_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_MAC_SET_LINK msgrequest */
+#define MC_CMD_FC_IN_MAC_SET_LINK_LEN 32
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_MAC_HEADER_OFST 4 */
+#define MC_CMD_FC_IN_MAC_SET_LINK_MTU_OFST 8
+#define MC_CMD_FC_IN_MAC_SET_LINK_DRAIN_OFST 12
+#define MC_CMD_FC_IN_MAC_SET_LINK_ADDR_OFST 16
+#define MC_CMD_FC_IN_MAC_SET_LINK_ADDR_LEN 8
+#define MC_CMD_FC_IN_MAC_SET_LINK_ADDR_LO_OFST 16
+#define MC_CMD_FC_IN_MAC_SET_LINK_ADDR_HI_OFST 20
+#define MC_CMD_FC_IN_MAC_SET_LINK_REJECT_OFST 24
+#define MC_CMD_FC_IN_MAC_SET_LINK_REJECT_UNICAST_LBN 0
+#define MC_CMD_FC_IN_MAC_SET_LINK_REJECT_UNICAST_WIDTH 1
+#define MC_CMD_FC_IN_MAC_SET_LINK_REJECT_BRDCAST_LBN 1
+#define MC_CMD_FC_IN_MAC_SET_LINK_REJECT_BRDCAST_WIDTH 1
+#define MC_CMD_FC_IN_MAC_SET_LINK_FCNTL_OFST 28
+
+/* MC_CMD_FC_IN_MAC_READ_STATUS msgrequest */
+#define MC_CMD_FC_IN_MAC_READ_STATUS_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_MAC_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_MAC_GET_RX_STATS msgrequest */
+#define MC_CMD_FC_IN_MAC_GET_RX_STATS_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_MAC_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_MAC_GET_TX_STATS msgrequest */
+#define MC_CMD_FC_IN_MAC_GET_TX_STATS_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_MAC_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_MAC_GET_STATS msgrequest */
+#define MC_CMD_FC_IN_MAC_GET_STATS_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_MAC_HEADER_OFST 4 */
+#define MC_CMD_FC_IN_MAC_GET_STATS_STATS_INDEX_OFST 8
+#define MC_CMD_FC_IN_MAC_GET_STATS_FLAGS_OFST 12
+#define MC_CMD_FC_IN_MAC_GET_STATS_CLEAR_ALL_LBN 0
+#define MC_CMD_FC_IN_MAC_GET_STATS_CLEAR_ALL_WIDTH 1
+#define MC_CMD_FC_IN_MAC_GET_STATS_CLEAR_LBN 1
+#define MC_CMD_FC_IN_MAC_GET_STATS_CLEAR_WIDTH 1
+#define MC_CMD_FC_IN_MAC_GET_STATS_UPDATE_LBN 2
+#define MC_CMD_FC_IN_MAC_GET_STATS_UPDATE_WIDTH 1
+#define MC_CMD_FC_IN_MAC_GET_STATS_NUM_OFST 16
+#define MC_CMD_FC_MAC_NSTATS_PER_BLOCK 0x1e /* enum */
+#define MC_CMD_FC_MAC_NBYTES_PER_STAT 0x8 /* enum */
+
+/* MC_CMD_FC_IN_READ32 msgrequest */
+#define MC_CMD_FC_IN_READ32_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_READ32_ADDR_HI_OFST 4
+#define MC_CMD_FC_IN_READ32_ADDR_LO_OFST 8
+#define MC_CMD_FC_IN_READ32_NUMWORDS_OFST 12
+
+/* MC_CMD_FC_IN_WRITE32 msgrequest */
+#define MC_CMD_FC_IN_WRITE32_LENMIN 16
+#define MC_CMD_FC_IN_WRITE32_LENMAX 252
+#define MC_CMD_FC_IN_WRITE32_LEN(num) (12+4*(num))
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_WRITE32_ADDR_HI_OFST 4
+#define MC_CMD_FC_IN_WRITE32_ADDR_LO_OFST 8
+#define MC_CMD_FC_IN_WRITE32_BUFFER_OFST 12
+#define MC_CMD_FC_IN_WRITE32_BUFFER_LEN 4
+#define MC_CMD_FC_IN_WRITE32_BUFFER_MINNUM 1
+#define MC_CMD_FC_IN_WRITE32_BUFFER_MAXNUM 60
+
+/* MC_CMD_FC_IN_TRC_READ msgrequest */
+#define MC_CMD_FC_IN_TRC_READ_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TRC_READ_TRC_OFST 4
+#define MC_CMD_FC_IN_TRC_READ_CHANNEL_OFST 8
+
+/* MC_CMD_FC_IN_TRC_WRITE msgrequest */
+#define MC_CMD_FC_IN_TRC_WRITE_LEN 28
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TRC_WRITE_TRC_OFST 4
+#define MC_CMD_FC_IN_TRC_WRITE_CHANNEL_OFST 8
+#define MC_CMD_FC_IN_TRC_WRITE_DATA_OFST 12
+#define MC_CMD_FC_IN_TRC_WRITE_DATA_LEN 4
+#define MC_CMD_FC_IN_TRC_WRITE_DATA_NUM 4
+
+/* MC_CMD_FC_IN_GET_VERSION msgrequest */
+#define MC_CMD_FC_IN_GET_VERSION_LEN 4
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+
+/* MC_CMD_FC_IN_TRC_RX_READ msgrequest */
+#define MC_CMD_FC_IN_TRC_RX_READ_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TRC_RX_READ_TRC_OFST 4
+#define MC_CMD_FC_IN_TRC_RX_READ_CHANNEL_OFST 8
+
+/* MC_CMD_FC_IN_TRC_RX_WRITE msgrequest */
+#define MC_CMD_FC_IN_TRC_RX_WRITE_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TRC_RX_WRITE_TRC_OFST 4
+#define MC_CMD_FC_IN_TRC_RX_WRITE_CHANNEL_OFST 8
+#define MC_CMD_FC_IN_TRC_RX_WRITE_DATA_OFST 12
+#define MC_CMD_FC_IN_TRC_RX_WRITE_DATA_LEN 4
+#define MC_CMD_FC_IN_TRC_RX_WRITE_DATA_NUM 2
+
+/* MC_CMD_FC_IN_SFP msgrequest */
+#define MC_CMD_FC_IN_SFP_LEN 24
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_SFP_SPEED_OFST 4
+#define MC_CMD_FC_IN_SFP_COPPER_LEN_OFST 8
+#define MC_CMD_FC_IN_SFP_DUAL_SPEED_OFST 12
+#define MC_CMD_FC_IN_SFP_PRESENT_OFST 16
+#define MC_CMD_FC_IN_SFP_TYPE_OFST 20
+
+/* MC_CMD_FC_IN_DDR_TEST msgrequest */
+#define MC_CMD_FC_IN_DDR_TEST_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DDR_TEST_HEADER_OFST 4
+#define MC_CMD_FC_IN_DDR_TEST_OP_LBN 0
+#define MC_CMD_FC_IN_DDR_TEST_OP_WIDTH 8
+#define MC_CMD_FC_OP_DDR_TEST_START 0x1 /* enum */
+#define MC_CMD_FC_OP_DDR_TEST_POLL 0x2 /* enum */
+
+/* MC_CMD_FC_IN_DDR_TEST_START msgrequest */
+#define MC_CMD_FC_IN_DDR_TEST_START_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_DDR_TEST_HEADER_OFST 4 */
+#define MC_CMD_FC_IN_DDR_TEST_START_MASK_OFST 8
+#define MC_CMD_FC_IN_DDR_TEST_START_T0_LBN 0
+#define MC_CMD_FC_IN_DDR_TEST_START_T0_WIDTH 1
+#define MC_CMD_FC_IN_DDR_TEST_START_T1_LBN 1
+#define MC_CMD_FC_IN_DDR_TEST_START_T1_WIDTH 1
+#define MC_CMD_FC_IN_DDR_TEST_START_B0_LBN 2
+#define MC_CMD_FC_IN_DDR_TEST_START_B0_WIDTH 1
+#define MC_CMD_FC_IN_DDR_TEST_START_B1_LBN 3
+#define MC_CMD_FC_IN_DDR_TEST_START_B1_WIDTH 1
+
+/* MC_CMD_FC_IN_DDR_TEST_POLL msgrequest */
+#define MC_CMD_FC_IN_DDR_TEST_POLL_LEN 8
+#define MC_CMD_FC_IN_DDR_TEST_CMD_OFST 0
+/* MC_CMD_FC_IN_DDR_TEST_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_GET_ASSERT msgrequest */
+#define MC_CMD_FC_IN_GET_ASSERT_LEN 4
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+
+/* MC_CMD_FC_IN_FPGA_BUILD msgrequest */
+#define MC_CMD_FC_IN_FPGA_BUILD_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_FPGA_BUILD_OP_OFST 4
+#define MC_CMD_FC_IN_FPGA_BUILD_BUILD 0x1 /* enum */
+#define MC_CMD_FC_IN_FPGA_BUILD_SERVICES 0x2 /* enum */
+#define MC_CMD_FC_IN_FPGA_BUILD_BSP_VERSION 0x3 /* enum */
+
+/* MC_CMD_FC_IN_READ_MAP msgrequest */
+#define MC_CMD_FC_IN_READ_MAP_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_READ_MAP_HEADER_OFST 4
+#define MC_CMD_FC_IN_READ_MAP_OP_LBN 0
+#define MC_CMD_FC_IN_READ_MAP_OP_WIDTH 8
+#define MC_CMD_FC_OP_READ_MAP_COUNT 0x1 /* enum */
+#define MC_CMD_FC_OP_READ_MAP_INDEX 0x2 /* enum */
+
+/* MC_CMD_FC_IN_READ_MAP_COUNT msgrequest */
+#define MC_CMD_FC_IN_READ_MAP_COUNT_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_READ_MAP_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_READ_MAP_INDEX msgrequest */
+#define MC_CMD_FC_IN_READ_MAP_INDEX_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_READ_MAP_HEADER_OFST 4 */
+#define MC_CMD_FC_IN_MAP_INDEX_OFST 8
+
+/* MC_CMD_FC_IN_CAPABILITIES msgrequest */
+#define MC_CMD_FC_IN_CAPABILITIES_LEN 4
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+
+/* MC_CMD_FC_IN_GLOBAL_FLAGS msgrequest */
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_FLAGS_OFST 4
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_RX_TUNING_CABLE_PLUGGED_IN_LBN 0
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_RX_TUNING_CABLE_PLUGGED_IN_WIDTH 1
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_RX_TUNING_LINK_MONITORING_LBN 1
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_RX_TUNING_LINK_MONITORING_WIDTH 1
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_DFE_ENABLE_LBN 2
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_DFE_ENABLE_WIDTH 1
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_1D_EYE_ENABLE_LBN 3
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_1D_EYE_ENABLE_WIDTH 1
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_1D_TUNING_ENABLE_LBN 4
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_1D_TUNING_ENABLE_WIDTH 1
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_OFFCAL_ENABLE_LBN 5
+#define MC_CMD_FC_IN_GLOBAL_FLAGS_OFFCAL_ENABLE_WIDTH 1
+
+/* MC_CMD_FC_IN_IO_REL msgrequest */
+#define MC_CMD_FC_IN_IO_REL_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_IO_REL_HEADER_OFST 4
+#define MC_CMD_FC_IN_IO_REL_OP_LBN 0
+#define MC_CMD_FC_IN_IO_REL_OP_WIDTH 8
+#define MC_CMD_FC_IN_IO_REL_GET_ADDR 0x1 /* enum */
+#define MC_CMD_FC_IN_IO_REL_READ32 0x2 /* enum */
+#define MC_CMD_FC_IN_IO_REL_WRITE32 0x3 /* enum */
+#define MC_CMD_FC_IN_IO_REL_COMP_TYPE_LBN 8
+#define MC_CMD_FC_IN_IO_REL_COMP_TYPE_WIDTH 8
+#define MC_CMD_FC_COMP_TYPE_APP_ADDR_SPACE 0x1 /* enum */
+#define MC_CMD_FC_COMP_TYPE_FLASH 0x2 /* enum */
+
+/* MC_CMD_FC_IN_IO_REL_GET_ADDR msgrequest */
+#define MC_CMD_FC_IN_IO_REL_GET_ADDR_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_IO_REL_HEADER_OFST 4 */
+
+/* MC_CMD_FC_IN_IO_REL_READ32 msgrequest */
+#define MC_CMD_FC_IN_IO_REL_READ32_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_IO_REL_HEADER_OFST 4 */
+#define MC_CMD_FC_IN_IO_REL_READ32_ADDR_HI_OFST 8
+#define MC_CMD_FC_IN_IO_REL_READ32_ADDR_LO_OFST 12
+#define MC_CMD_FC_IN_IO_REL_READ32_NUMWORDS_OFST 16
+
+/* MC_CMD_FC_IN_IO_REL_WRITE32 msgrequest */
+#define MC_CMD_FC_IN_IO_REL_WRITE32_LENMIN 20
+#define MC_CMD_FC_IN_IO_REL_WRITE32_LENMAX 252
+#define MC_CMD_FC_IN_IO_REL_WRITE32_LEN(num) (16+4*(num))
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_IO_REL_HEADER_OFST 4 */
+#define MC_CMD_FC_IN_IO_REL_WRITE32_ADDR_HI_OFST 8
+#define MC_CMD_FC_IN_IO_REL_WRITE32_ADDR_LO_OFST 12
+#define MC_CMD_FC_IN_IO_REL_WRITE32_BUFFER_OFST 16
+#define MC_CMD_FC_IN_IO_REL_WRITE32_BUFFER_LEN 4
+#define MC_CMD_FC_IN_IO_REL_WRITE32_BUFFER_MINNUM 1
+#define MC_CMD_FC_IN_IO_REL_WRITE32_BUFFER_MAXNUM 59
+
+/* MC_CMD_FC_IN_UHLINK msgrequest */
+#define MC_CMD_FC_IN_UHLINK_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_UHLINK_HEADER_OFST 4
+#define MC_CMD_FC_IN_UHLINK_OP_LBN 0
+#define MC_CMD_FC_IN_UHLINK_OP_WIDTH 8
+#define MC_CMD_FC_OP_UHLINK_PHY 0x1 /* enum */
+#define MC_CMD_FC_OP_UHLINK_MAC 0x2 /* enum */
+#define MC_CMD_FC_OP_UHLINK_RX_EYE 0x3 /* enum */
+#define MC_CMD_FC_OP_UHLINK_DUMP_RX_EYE_PLOT 0x4 /* enum */
+#define MC_CMD_FC_OP_UHLINK_READ_RX_EYE_PLOT 0x5 /* enum */
+#define MC_CMD_FC_OP_UHLINK_RX_TUNE 0x6 /* enum */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_SET 0x7 /* enum */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_GET 0x8 /* enum */
+#define MC_CMD_FC_IN_UHLINK_PORT_TYPE_LBN 8
+#define MC_CMD_FC_IN_UHLINK_PORT_TYPE_WIDTH 8
+#define MC_CMD_FC_IN_UHLINK_PORT_IDX_LBN 16
+#define MC_CMD_FC_IN_UHLINK_PORT_IDX_WIDTH 8
+#define MC_CMD_FC_IN_UHLINK_CMD_FORMAT_LBN 24
+#define MC_CMD_FC_IN_UHLINK_CMD_FORMAT_WIDTH 8
+#define MC_CMD_FC_OP_UHLINK_CMD_FORMAT_DEFAULT 0x0 /* enum */
+#define MC_CMD_FC_OP_UHLINK_CMD_FORMAT_PORT_OVERRIDE 0x1 /* enum */
+
+/* MC_CMD_FC_OP_UHLINK_PHY msgrequest */
+#define MC_CMD_FC_OP_UHLINK_PHY_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+
+/* MC_CMD_FC_OP_UHLINK_MAC msgrequest */
+#define MC_CMD_FC_OP_UHLINK_MAC_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+
+/* MC_CMD_FC_OP_UHLINK_RX_EYE msgrequest */
+#define MC_CMD_FC_OP_UHLINK_RX_EYE_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+#define MC_CMD_FC_OP_UHLINK_RX_EYE_INDEX_OFST 8
+#define MC_CMD_FC_UHLINK_RX_EYE_PER_BLOCK 0x30 /* enum */
+
+/* MC_CMD_FC_OP_UHLINK_DUMP_RX_EYE_PLOT msgrequest */
+#define MC_CMD_FC_OP_UHLINK_DUMP_RX_EYE_PLOT_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+
+/* MC_CMD_FC_OP_UHLINK_READ_RX_EYE_PLOT msgrequest */
+#define MC_CMD_FC_OP_UHLINK_READ_RX_EYE_PLOT_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+#define MC_CMD_FC_OP_UHLINK_READ_RX_EYE_PLOT_DC_GAIN_OFST 8
+#define MC_CMD_FC_OP_UHLINK_READ_RX_EYE_PLOT_EQ_CONTROL_OFST 12
+#define MC_CMD_FC_OP_UHLINK_READ_RX_EYE_PLOT_INDEX_OFST 16
+#define MC_CMD_FC_UHLINK_RX_EYE_PLOT_ROWS_PER_BLOCK 0x1e /* enum */
+
+/* MC_CMD_FC_OP_UHLINK_RX_TUNE msgrequest */
+#define MC_CMD_FC_OP_UHLINK_RX_TUNE_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+
+/* MC_CMD_FC_OP_UHLINK_LOOPBACK_SET msgrequest */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_SET_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_SET_TYPE_OFST 8
+#define MC_CMD_FC_UHLINK_LOOPBACK_TYPE_PCS_SERIAL 0x0 /* enum */
+#define MC_CMD_FC_UHLINK_LOOPBACK_TYPE_PMA_PRE_CDR 0x1 /* enum */
+#define MC_CMD_FC_UHLINK_LOOPBACK_TYPE_PMA_POST_CDR 0x2 /* enum */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_SET_STATE_OFST 12
+#define MC_CMD_FC_UHLINK_LOOPBACK_STATE_OFF 0x0 /* enum */
+#define MC_CMD_FC_UHLINK_LOOPBACK_STATE_ON 0x1 /* enum */
+
+/* MC_CMD_FC_OP_UHLINK_LOOPBACK_GET msgrequest */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_GET_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_UHLINK_HEADER_OFST 4 */
+#define MC_CMD_FC_OP_UHLINK_LOOPBACK_GET_TYPE_OFST 8
+
+/* MC_CMD_FC_IN_SET_LINK msgrequest */
+#define MC_CMD_FC_IN_SET_LINK_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_SET_LINK_MODE_OFST 4
+#define MC_CMD_FC_IN_SET_LINK_SPEED_OFST 8
+#define MC_CMD_FC_IN_SET_LINK_FLAGS_OFST 12
+#define MC_CMD_FC_IN_SET_LINK_LOWPOWER_LBN 0
+#define MC_CMD_FC_IN_SET_LINK_LOWPOWER_WIDTH 1
+#define MC_CMD_FC_IN_SET_LINK_POWEROFF_LBN 1
+#define MC_CMD_FC_IN_SET_LINK_POWEROFF_WIDTH 1
+#define MC_CMD_FC_IN_SET_LINK_TXDIS_LBN 2
+#define MC_CMD_FC_IN_SET_LINK_TXDIS_WIDTH 1
+
+/* MC_CMD_FC_IN_LICENSE msgrequest */
+#define MC_CMD_FC_IN_LICENSE_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_LICENSE_OP_OFST 4
+#define MC_CMD_FC_IN_LICENSE_UPDATE_LICENSE 0x0 /* enum */
+#define MC_CMD_FC_IN_LICENSE_GET_KEY_STATS 0x1 /* enum */
+
+/* MC_CMD_FC_IN_STARTUP msgrequest */
+#define MC_CMD_FC_IN_STARTUP_LEN 40
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_STARTUP_BASE_OFST 4
+#define MC_CMD_FC_IN_STARTUP_LENGTH_OFST 8
+#define MC_CMD_FC_IN_STARTUP_IDLENGTH_OFST 12
+#define MC_CMD_FC_IN_STARTUP_ID_OFST 16
+#define MC_CMD_FC_IN_STARTUP_ID_LEN 1
+#define MC_CMD_FC_IN_STARTUP_ID_NUM 24
+
+/* MC_CMD_FC_IN_DMA msgrequest */
+#define MC_CMD_FC_IN_DMA_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DMA_OP_OFST 4
+#define MC_CMD_FC_IN_DMA_STOP 0x0 /* enum */
+#define MC_CMD_FC_IN_DMA_READ 0x1 /* enum */
+
+/* MC_CMD_FC_IN_DMA_STOP msgrequest */
+#define MC_CMD_FC_IN_DMA_STOP_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_DMA_OP_OFST 4 */
+#define MC_CMD_FC_IN_DMA_STOP_FC_HANDLE_OFST 8
+
+/* MC_CMD_FC_IN_DMA_READ msgrequest */
+#define MC_CMD_FC_IN_DMA_READ_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_DMA_OP_OFST 4 */
+#define MC_CMD_FC_IN_DMA_READ_OFFSET_OFST 8
+#define MC_CMD_FC_IN_DMA_READ_LENGTH_OFST 12
+
+/* MC_CMD_FC_IN_TIMED_READ msgrequest */
+#define MC_CMD_FC_IN_TIMED_READ_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TIMED_READ_OP_OFST 4
+#define MC_CMD_FC_IN_TIMED_READ_SET 0x0 /* enum */
+#define MC_CMD_FC_IN_TIMED_READ_GET 0x1 /* enum */
+#define MC_CMD_FC_IN_TIMED_READ_CLEAR 0x2 /* enum */
+
+/* MC_CMD_FC_IN_TIMED_READ_SET msgrequest */
+#define MC_CMD_FC_IN_TIMED_READ_SET_LEN 52
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_TIMED_READ_OP_OFST 4 */
+#define MC_CMD_FC_IN_TIMED_READ_SET_HOST_HANDLE_OFST 8
+#define MC_CMD_FC_IN_TIMED_READ_SET_HOST_DMA_ADDRESS_OFST 12
+#define MC_CMD_FC_IN_TIMED_READ_SET_HOST_DMA_ADDRESS_LEN 8
+#define MC_CMD_FC_IN_TIMED_READ_SET_HOST_DMA_ADDRESS_LO_OFST 12
+#define MC_CMD_FC_IN_TIMED_READ_SET_HOST_DMA_ADDRESS_HI_OFST 16
+#define MC_CMD_FC_IN_TIMED_READ_SET_AOE_ADDRESS_OFST 20
+#define MC_CMD_FC_IN_TIMED_READ_SET_AOE_ADDRESS_LEN 8
+#define MC_CMD_FC_IN_TIMED_READ_SET_AOE_ADDRESS_LO_OFST 20
+#define MC_CMD_FC_IN_TIMED_READ_SET_AOE_ADDRESS_HI_OFST 24
+#define MC_CMD_FC_IN_TIMED_READ_SET_AOE_LENGTH_OFST 28
+#define MC_CMD_FC_IN_TIMED_READ_SET_HOST_LENGTH_OFST 32
+#define MC_CMD_FC_IN_TIMED_READ_SET_OFFSET_OFST 36
+#define MC_CMD_FC_IN_TIMED_READ_SET_DATA_OFST 40
+#define MC_CMD_FC_IN_TIMED_READ_SET_FLAGS_OFST 44
+#define MC_CMD_FC_IN_TIMED_READ_SET_INDIRECT_LBN 0
+#define MC_CMD_FC_IN_TIMED_READ_SET_INDIRECT_WIDTH 1
+#define MC_CMD_FC_IN_TIMED_READ_SET_DOUBLE_LBN 1
+#define MC_CMD_FC_IN_TIMED_READ_SET_DOUBLE_WIDTH 1
+#define MC_CMD_FC_IN_TIMED_READ_SET_EVENT_LBN 2
+#define MC_CMD_FC_IN_TIMED_READ_SET_EVENT_WIDTH 1
+#define MC_CMD_FC_IN_TIMED_READ_SET_PREREAD_LBN 3
+#define MC_CMD_FC_IN_TIMED_READ_SET_PREREAD_WIDTH 2
+#define MC_CMD_FC_IN_TIMED_READ_SET_NONE 0x0 /* enum */
+#define MC_CMD_FC_IN_TIMED_READ_SET_READ 0x1 /* enum */
+#define MC_CMD_FC_IN_TIMED_READ_SET_WRITE 0x2 /* enum */
+#define MC_CMD_FC_IN_TIMED_READ_SET_READWRITE 0x3 /* enum */
+#define MC_CMD_FC_IN_TIMED_READ_SET_PERIOD_OFST 48
+
+/* MC_CMD_FC_IN_TIMED_READ_GET msgrequest */
+#define MC_CMD_FC_IN_TIMED_READ_GET_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_TIMED_READ_OP_OFST 4 */
+#define MC_CMD_FC_IN_TIMED_READ_GET_FC_HANDLE_OFST 8
+
+/* MC_CMD_FC_IN_TIMED_READ_CLEAR msgrequest */
+#define MC_CMD_FC_IN_TIMED_READ_CLEAR_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_TIMED_READ_OP_OFST 4 */
+#define MC_CMD_FC_IN_TIMED_READ_CLEAR_FC_HANDLE_OFST 8
+
+/* MC_CMD_FC_IN_LOG msgrequest */
+#define MC_CMD_FC_IN_LOG_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_LOG_OP_OFST 4
+#define MC_CMD_FC_IN_LOG_ADDR_RANGE 0x0 /* enum */
+#define MC_CMD_FC_IN_LOG_JTAG_UART 0x1 /* enum */
+
+/* MC_CMD_FC_IN_LOG_ADDR_RANGE msgrequest */
+#define MC_CMD_FC_IN_LOG_ADDR_RANGE_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_LOG_OP_OFST 4 */
+#define MC_CMD_FC_IN_LOG_ADDR_RANGE_OFFSET_OFST 8
+#define MC_CMD_FC_IN_LOG_ADDR_RANGE_LENGTH_OFST 12
+#define MC_CMD_FC_IN_LOG_ADDR_RANGE_ERASE_SIZE_OFST 16
+
+/* MC_CMD_FC_IN_LOG_JTAG_UART msgrequest */
+#define MC_CMD_FC_IN_LOG_JTAG_UART_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_LOG_OP_OFST 4 */
+#define MC_CMD_FC_IN_LOG_JTAG_UART_ENABLE_OFST 8
+
+/* MC_CMD_FC_IN_CLOCK msgrequest */
+#define MC_CMD_FC_IN_CLOCK_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_CLOCK_OP_OFST 4
+#define MC_CMD_FC_IN_CLOCK_GET_TIME 0x0 /* enum */
+#define MC_CMD_FC_IN_CLOCK_SET_TIME 0x1 /* enum */
+#define MC_CMD_FC_IN_CLOCK_ID_OFST 8
+#define MC_CMD_FC_IN_CLOCK_STATS 0x0 /* enum */
+#define MC_CMD_FC_IN_CLOCK_MAC 0x1 /* enum */
+
+/* MC_CMD_FC_IN_CLOCK_GET_TIME msgrequest */
+#define MC_CMD_FC_IN_CLOCK_GET_TIME_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_CLOCK_OP_OFST 4 */
+/* MC_CMD_FC_IN_CLOCK_ID_OFST 8 */
+
+/* MC_CMD_FC_IN_CLOCK_SET_TIME msgrequest */
+#define MC_CMD_FC_IN_CLOCK_SET_TIME_LEN 24
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_CLOCK_OP_OFST 4 */
+/* MC_CMD_FC_IN_CLOCK_ID_OFST 8 */
+#define MC_CMD_FC_IN_CLOCK_SET_TIME_SECONDS_OFST 12
+#define MC_CMD_FC_IN_CLOCK_SET_TIME_SECONDS_LEN 8
+#define MC_CMD_FC_IN_CLOCK_SET_TIME_SECONDS_LO_OFST 12
+#define MC_CMD_FC_IN_CLOCK_SET_TIME_SECONDS_HI_OFST 16
+#define MC_CMD_FC_IN_CLOCK_SET_TIME_NANOSECONDS_OFST 20
+
+/* MC_CMD_FC_IN_DDR msgrequest */
+#define MC_CMD_FC_IN_DDR_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DDR_OP_OFST 4
+#define MC_CMD_FC_IN_DDR_SET_SPD 0x0 /* enum */
+#define MC_CMD_FC_IN_DDR_GET_STATUS 0x1 /* enum */
+#define MC_CMD_FC_IN_DDR_BANK_OFST 8
+#define MC_CMD_FC_IN_DDR_BANK_B0 0x0 /* enum */
+#define MC_CMD_FC_IN_DDR_BANK_B1 0x1 /* enum */
+#define MC_CMD_FC_IN_DDR_BANK_T0 0x2 /* enum */
+#define MC_CMD_FC_IN_DDR_BANK_T1 0x3 /* enum */
+#define MC_CMD_FC_IN_DDR_NUM_BANKS 0x4 /* enum */
+
+/* MC_CMD_FC_IN_DDR_SET_SPD msgrequest */
+#define MC_CMD_FC_IN_DDR_SET_SPD_LEN 148
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_DDR_OP_OFST 4 */
+/* MC_CMD_FC_IN_DDR_BANK_OFST 8 */
+#define MC_CMD_FC_IN_DDR_FLAGS_OFST 12
+#define MC_CMD_FC_IN_DDR_SET_SPD_ACTIVE 0x1 /* enum */
+#define MC_CMD_FC_IN_DDR_SPD_OFST 16
+#define MC_CMD_FC_IN_DDR_SPD_LEN 1
+#define MC_CMD_FC_IN_DDR_SPD_NUM 128
+#define MC_CMD_FC_IN_DDR_SPD_PAGE_ID_OFST 144
+
+/* MC_CMD_FC_IN_DDR_GET_STATUS msgrequest */
+#define MC_CMD_FC_IN_DDR_GET_STATUS_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+/* MC_CMD_FC_IN_DDR_OP_OFST 4 */
+/* MC_CMD_FC_IN_DDR_BANK_OFST 8 */
+
+/* MC_CMD_FC_IN_TIMESTAMP msgrequest */
+#define MC_CMD_FC_IN_TIMESTAMP_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TIMESTAMP_OP_OFST 4
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT 0x0 /* enum */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_SNAPSHOT 0x1 /* enum */
+#define MC_CMD_FC_IN_TIMESTAMP_CLEAR_TRANSMIT 0x2 /* enum */
+
+/* MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT msgrequest */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_LEN 28
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_OP_OFST 4
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_FILTER_OFST 8
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_LATEST 0x0 /* enum */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_MATCH 0x1 /* enum */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_CLOCK_ID_OFST 12
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_CLOCK_ID_LEN 8
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_CLOCK_ID_LO_OFST 12
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_CLOCK_ID_HI_OFST 16
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_PORT_NUM_OFST 20
+#define MC_CMD_FC_IN_TIMESTAMP_READ_TRANSMIT_SEQ_NUM_OFST 24
+
+/* MC_CMD_FC_IN_TIMESTAMP_READ_SNAPSHOT msgrequest */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_SNAPSHOT_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TIMESTAMP_READ_SNAPSHOT_OP_OFST 4
+
+/* MC_CMD_FC_IN_TIMESTAMP_CLEAR_TRANSMIT msgrequest */
+#define MC_CMD_FC_IN_TIMESTAMP_CLEAR_TRANSMIT_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_TIMESTAMP_CLEAR_TRANSMIT_OP_OFST 4
+
+/* MC_CMD_FC_IN_SPI msgrequest */
+#define MC_CMD_FC_IN_SPI_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_SPI_OP_OFST 4
+#define MC_CMD_FC_IN_SPI_READ 0x0 /* enum */
+#define MC_CMD_FC_IN_SPI_WRITE 0x1 /* enum */
+#define MC_CMD_FC_IN_SPI_ERASE 0x2 /* enum */
+
+/* MC_CMD_FC_IN_SPI_READ msgrequest */
+#define MC_CMD_FC_IN_SPI_READ_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_SPI_READ_OP_OFST 4
+#define MC_CMD_FC_IN_SPI_READ_ADDR_OFST 8
+#define MC_CMD_FC_IN_SPI_READ_NUMBYTES_OFST 12
+
+/* MC_CMD_FC_IN_SPI_WRITE msgrequest */
+#define MC_CMD_FC_IN_SPI_WRITE_LENMIN 16
+#define MC_CMD_FC_IN_SPI_WRITE_LENMAX 252
+#define MC_CMD_FC_IN_SPI_WRITE_LEN(num) (12+4*(num))
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_SPI_WRITE_OP_OFST 4
+#define MC_CMD_FC_IN_SPI_WRITE_ADDR_OFST 8
+#define MC_CMD_FC_IN_SPI_WRITE_BUFFER_OFST 12
+#define MC_CMD_FC_IN_SPI_WRITE_BUFFER_LEN 4
+#define MC_CMD_FC_IN_SPI_WRITE_BUFFER_MINNUM 1
+#define MC_CMD_FC_IN_SPI_WRITE_BUFFER_MAXNUM 60
+
+/* MC_CMD_FC_IN_SPI_ERASE msgrequest */
+#define MC_CMD_FC_IN_SPI_ERASE_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_SPI_ERASE_OP_OFST 4
+#define MC_CMD_FC_IN_SPI_ERASE_ADDR_OFST 8
+#define MC_CMD_FC_IN_SPI_ERASE_NUMBYTES_OFST 12
+
+/* MC_CMD_FC_IN_DIAG msgrequest */
+#define MC_CMD_FC_IN_DIAG_LEN 8
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK 0x1 /* enum */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL 0x2 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_POWER_NOISE msgrequest */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_READ_CONFIG 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG 0x1 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_POWER_NOISE_READ_CONFIG msgrequest */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_READ_CONFIG_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_READ_CONFIG_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_READ_CONFIG_SUB_OP_OFST 8
+
+/* MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG msgrequest */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG_TOGGLE_COUNT_OFST 12
+#define MC_CMD_FC_IN_DIAG_POWER_NOISE_WRITE_CONFIG_CLKEN_COUNT_OFST 16
+
+/* MC_CMD_FC_IN_DIAG_DDR_SOAK msgrequest */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_RESULT 0x1 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_STOP 0x2 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR 0x3 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_DDR_SOAK_START msgrequest */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_LEN 24
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_BANK_MASK_OFST 12
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_TEST_PATTERN_OFST 16
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_ZEROS 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_ONES 0x1 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_TEST_TYPE_OFST 20
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_ONGOING_TEST 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_START_SINGLE_TEST 0x1 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_DDR_SOAK_RESULT msgrequest */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_RESULT_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_RESULT_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_RESULT_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_RESULT_BANK_ID_OFST 12
+#define MC_CMD_FC_DDR_BANK0 0x0 /* enum */
+#define MC_CMD_FC_DDR_BANK1 0x1 /* enum */
+#define MC_CMD_FC_DDR_BANK2 0x2 /* enum */
+#define MC_CMD_FC_DDR_BANK3 0x3 /* enum */
+#define MC_CMD_FC_DDR_AOEMEM_MAX_BANKS 0x4 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_DDR_SOAK_STOP msgrequest */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_STOP_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_STOP_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_STOP_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_STOP_BANK_MASK_OFST 12
+
+/* MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR msgrequest */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_LEN 20
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_BANK_MASK_OFST 12
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_FLAG_ACTION_OFST 16
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_CLEAR 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DDR_SOAK_ERROR_SET 0x1 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_DATAPATH_CTRL msgrequest */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_LEN 12
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG 0x1 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE msgrequest */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE_LEN 16
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE_MODE_OFST 12
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE_PASSTHROUGH 0x0 /* enum */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_SET_MODE_SNAKE 0x1 /* enum */
+
+/* MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG msgrequest */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG_LEN 24
+/* MC_CMD_FC_IN_CMD_OFST 0 */
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG_OP_OFST 4
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG_SUB_OP_OFST 8
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG_CONTROL1_OFST 12
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG_CONTROL2_OFST 16
+#define MC_CMD_FC_IN_DIAG_DATAPATH_CTRL_RAW_CONFIG_CONTROL3_OFST 20
+
+/* MC_CMD_FC_OUT msgresponse */
+#define MC_CMD_FC_OUT_LEN 0
+
+/* MC_CMD_FC_OUT_NULL msgresponse */
+#define MC_CMD_FC_OUT_NULL_LEN 0
+
+/* MC_CMD_FC_OUT_READ32 msgresponse */
+#define MC_CMD_FC_OUT_READ32_LENMIN 4
+#define MC_CMD_FC_OUT_READ32_LENMAX 252
+#define MC_CMD_FC_OUT_READ32_LEN(num) (0+4*(num))
+#define MC_CMD_FC_OUT_READ32_BUFFER_OFST 0
+#define MC_CMD_FC_OUT_READ32_BUFFER_LEN 4
+#define MC_CMD_FC_OUT_READ32_BUFFER_MINNUM 1
+#define MC_CMD_FC_OUT_READ32_BUFFER_MAXNUM 63
+
+/* MC_CMD_FC_OUT_WRITE32 msgresponse */
+#define MC_CMD_FC_OUT_WRITE32_LEN 0
+
+/* MC_CMD_FC_OUT_TRC_READ msgresponse */
+#define MC_CMD_FC_OUT_TRC_READ_LEN 16
+#define MC_CMD_FC_OUT_TRC_READ_DATA_OFST 0
+#define MC_CMD_FC_OUT_TRC_READ_DATA_LEN 4
+#define MC_CMD_FC_OUT_TRC_READ_DATA_NUM 4
+
+/* MC_CMD_FC_OUT_TRC_WRITE msgresponse */
+#define MC_CMD_FC_OUT_TRC_WRITE_LEN 0
+
+/* MC_CMD_FC_OUT_GET_VERSION msgresponse */
+#define MC_CMD_FC_OUT_GET_VERSION_LEN 12
+#define MC_CMD_FC_OUT_GET_VERSION_FIRMWARE_OFST 0
+#define MC_CMD_FC_OUT_GET_VERSION_VERSION_OFST 4
+#define MC_CMD_FC_OUT_GET_VERSION_VERSION_LEN 8
+#define MC_CMD_FC_OUT_GET_VERSION_VERSION_LO_OFST 4
+#define MC_CMD_FC_OUT_GET_VERSION_VERSION_HI_OFST 8
+
+/* MC_CMD_FC_OUT_TRC_RX_READ msgresponse */
+#define MC_CMD_FC_OUT_TRC_RX_READ_LEN 8
+#define MC_CMD_FC_OUT_TRC_RX_READ_DATA_OFST 0
+#define MC_CMD_FC_OUT_TRC_RX_READ_DATA_LEN 4
+#define MC_CMD_FC_OUT_TRC_RX_READ_DATA_NUM 2
+
+/* MC_CMD_FC_OUT_TRC_RX_WRITE msgresponse */
+#define MC_CMD_FC_OUT_TRC_RX_WRITE_LEN 0
+
+/* MC_CMD_FC_OUT_MAC_RECONFIGURE msgresponse */
+#define MC_CMD_FC_OUT_MAC_RECONFIGURE_LEN 0
+
+/* MC_CMD_FC_OUT_MAC_SET_LINK msgresponse */
+#define MC_CMD_FC_OUT_MAC_SET_LINK_LEN 0
+
+/* MC_CMD_FC_OUT_MAC_READ_STATUS msgresponse */
+#define MC_CMD_FC_OUT_MAC_READ_STATUS_LEN 4
+#define MC_CMD_FC_OUT_MAC_READ_STATUS_STATUS_OFST 0
+
+/* MC_CMD_FC_OUT_MAC_GET_RX_STATS msgresponse */
+#define MC_CMD_FC_OUT_MAC_GET_RX_STATS_LEN ((((0-1+(64*MC_CMD_FC_MAC_RX_NSTATS))+1))>>3)
+#define MC_CMD_FC_OUT_MAC_GET_RX_STATS_STATISTICS_OFST 0
+#define MC_CMD_FC_OUT_MAC_GET_RX_STATS_STATISTICS_LEN 8
+#define MC_CMD_FC_OUT_MAC_GET_RX_STATS_STATISTICS_LO_OFST 0
+#define MC_CMD_FC_OUT_MAC_GET_RX_STATS_STATISTICS_HI_OFST 4
+#define MC_CMD_FC_OUT_MAC_GET_RX_STATS_STATISTICS_NUM MC_CMD_FC_MAC_RX_NSTATS
+#define MC_CMD_FC_MAC_RX_STATS_OCTETS 0x0 /* enum */
+#define MC_CMD_FC_MAC_RX_OCTETS_OK 0x1 /* enum */
+#define MC_CMD_FC_MAC_RX_ALIGNMENT_ERRORS 0x2 /* enum */
+#define MC_CMD_FC_MAC_RX_PAUSE_MAC_CTRL_FRAMES 0x3 /* enum */
+#define MC_CMD_FC_MAC_RX_FRAMES_OK 0x4 /* enum */
+#define MC_CMD_FC_MAC_RX_CRC_ERRORS 0x5 /* enum */
+#define MC_CMD_FC_MAC_RX_VLAN_OK 0x6 /* enum */
+#define MC_CMD_FC_MAC_RX_ERRORS 0x7 /* enum */
+#define MC_CMD_FC_MAC_RX_UCAST_PKTS 0x8 /* enum */
+#define MC_CMD_FC_MAC_RX_MULTICAST_PKTS 0x9 /* enum */
+#define MC_CMD_FC_MAC_RX_BROADCAST_PKTS 0xa /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_DROP_EVENTS 0xb /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS 0xc /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_UNDERSIZE_PKTS 0xd /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_64 0xe /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_65_127 0xf /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_128_255 0x10 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_256_511 0x11 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_512_1023 0x12 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_1024_1518 0x13 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_PKTS_1519_MAX 0x14 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_OVERSIZE_PKTS 0x15 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_JABBERS 0x16 /* enum */
+#define MC_CMD_FC_MAC_RX_STATS_FRAGMENTS 0x17 /* enum */
+#define MC_CMD_FC_MAC_RX_MAC_CONTROL_FRAMES 0x18 /* enum */
+#define MC_CMD_FC_MAC_RX_NSTATS 0x19 /* enum */
+
+/* MC_CMD_FC_OUT_MAC_GET_TX_STATS msgresponse */
+#define MC_CMD_FC_OUT_MAC_GET_TX_STATS_LEN ((((0-1+(64*MC_CMD_FC_MAC_TX_NSTATS))+1))>>3)
+#define MC_CMD_FC_OUT_MAC_GET_TX_STATS_STATISTICS_OFST 0
+#define MC_CMD_FC_OUT_MAC_GET_TX_STATS_STATISTICS_LEN 8
+#define MC_CMD_FC_OUT_MAC_GET_TX_STATS_STATISTICS_LO_OFST 0
+#define MC_CMD_FC_OUT_MAC_GET_TX_STATS_STATISTICS_HI_OFST 4
+#define MC_CMD_FC_OUT_MAC_GET_TX_STATS_STATISTICS_NUM MC_CMD_FC_MAC_TX_NSTATS
+#define MC_CMD_FC_MAC_TX_STATS_OCTETS 0x0 /* enum */
+#define MC_CMD_FC_MAC_TX_OCTETS_OK 0x1 /* enum */
+#define MC_CMD_FC_MAC_TX_ALIGNMENT_ERRORS 0x2 /* enum */
+#define MC_CMD_FC_MAC_TX_PAUSE_MAC_CTRL_FRAMES 0x3 /* enum */
+#define MC_CMD_FC_MAC_TX_FRAMES_OK 0x4 /* enum */
+#define MC_CMD_FC_MAC_TX_CRC_ERRORS 0x5 /* enum */
+#define MC_CMD_FC_MAC_TX_VLAN_OK 0x6 /* enum */
+#define MC_CMD_FC_MAC_TX_ERRORS 0x7 /* enum */
+#define MC_CMD_FC_MAC_TX_UCAST_PKTS 0x8 /* enum */
+#define MC_CMD_FC_MAC_TX_MULTICAST_PKTS 0x9 /* enum */
+#define MC_CMD_FC_MAC_TX_BROADCAST_PKTS 0xa /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_DROP_EVENTS 0xb /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS 0xc /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_UNDERSIZE_PKTS 0xd /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_64 0xe /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_65_127 0xf /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_128_255 0x10 /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_256_511 0x11 /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_512_1023 0x12 /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_1024_1518 0x13 /* enum */
+#define MC_CMD_FC_MAC_TX_STATS_PKTS_1519_TX_MTU 0x14 /* enum */
+#define MC_CMD_FC_MAC_TX_MAC_CONTROL_FRAMES 0x15 /* enum */
+#define MC_CMD_FC_MAC_TX_NSTATS 0x16 /* enum */
+
+/* MC_CMD_FC_OUT_MAC_GET_STATS msgresponse */
+#define MC_CMD_FC_OUT_MAC_GET_STATS_LEN ((((0-1+(64*MC_CMD_FC_MAC_NSTATS_PER_BLOCK))+1))>>3)
+#define MC_CMD_FC_OUT_MAC_GET_STATS_STATISTICS_OFST 0
+#define MC_CMD_FC_OUT_MAC_GET_STATS_STATISTICS_LEN 8
+#define MC_CMD_FC_OUT_MAC_GET_STATS_STATISTICS_LO_OFST 0
+#define MC_CMD_FC_OUT_MAC_GET_STATS_STATISTICS_HI_OFST 4
+#define MC_CMD_FC_OUT_MAC_GET_STATS_STATISTICS_NUM MC_CMD_FC_MAC_NSTATS_PER_BLOCK
+
+/* MC_CMD_FC_OUT_MAC msgresponse */
+#define MC_CMD_FC_OUT_MAC_LEN 0
+
+/* MC_CMD_FC_OUT_SFP msgresponse */
+#define MC_CMD_FC_OUT_SFP_LEN 0
+
+/* MC_CMD_FC_OUT_DDR_TEST_START msgresponse */
+#define MC_CMD_FC_OUT_DDR_TEST_START_LEN 0
+
+/* MC_CMD_FC_OUT_DDR_TEST_POLL msgresponse */
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_LEN 8
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_STATUS_OFST 0
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_CODE_LBN 0
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_CODE_WIDTH 8
+#define MC_CMD_FC_OP_DDR_TEST_NONE 0x0 /* enum */
+#define MC_CMD_FC_OP_DDR_TEST_INPROGRESS 0x1 /* enum */
+#define MC_CMD_FC_OP_DDR_TEST_SUCCESS 0x2 /* enum */
+#define MC_CMD_FC_OP_DDR_TEST_TIMER_EXPIRED 0x3 /* enum */
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_T0_LBN 11
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_T0_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_T1_LBN 10
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_T1_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_B0_LBN 9
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_B0_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_B1_LBN 8
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_PRESENT_B1_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_RESULT_OFST 4
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_T0_LBN 31
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_T0_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_T1_LBN 30
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_T1_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_B0_LBN 29
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_B0_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_B1_LBN 28
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_FPGA_SUPPORTS_B1_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_T0_LBN 15
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_T0_WIDTH 5
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_T1_LBN 10
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_T1_WIDTH 5
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_B0_LBN 5
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_B0_WIDTH 5
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_B1_LBN 0
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_B1_WIDTH 5
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_TEST_COMPLETE 0x0 /* enum */
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_TEST_FAIL 0x1 /* enum */
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_TEST_PASS 0x2 /* enum */
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_CAL_FAIL 0x3 /* enum */
+#define MC_CMD_FC_OUT_DDR_TEST_POLL_CAL_SUCCESS 0x4 /* enum */
+
+/* MC_CMD_FC_OUT_DDR_TEST msgresponse */
+#define MC_CMD_FC_OUT_DDR_TEST_LEN 0
+
+/* MC_CMD_FC_OUT_GET_ASSERT msgresponse */
+#define MC_CMD_FC_OUT_GET_ASSERT_LEN 144
+#define MC_CMD_FC_OUT_GET_ASSERT_GLOBAL_FLAGS_OFST 0
+#define MC_CMD_FC_OUT_GET_ASSERT_STATE_LBN 8
+#define MC_CMD_FC_OUT_GET_ASSERT_STATE_WIDTH 8
+#define MC_CMD_FC_GET_ASSERT_FLAGS_STATE_CLEAR 0x0 /* enum */
+#define MC_CMD_FC_GET_ASSERT_FLAGS_STATE_NEW 0x1 /* enum */
+#define MC_CMD_FC_GET_ASSERT_FLAGS_STATE_NOTIFIED 0x2 /* enum */
+#define MC_CMD_FC_OUT_GET_ASSERT_TYPE_LBN 0
+#define MC_CMD_FC_OUT_GET_ASSERT_TYPE_WIDTH 8
+#define MC_CMD_FC_GET_ASSERT_FLAGS_TYPE_NONE 0x0 /* enum */
+#define MC_CMD_FC_GET_ASSERT_FLAGS_TYPE_EXCEPTION 0x1 /* enum */
+#define MC_CMD_FC_GET_ASSERT_FLAGS_TYPE_ASSERTION 0x2 /* enum */
+#define MC_CMD_FC_OUT_GET_ASSERT_SAVED_PC_OFFS_OFST 4
+#define MC_CMD_FC_OUT_GET_ASSERT_GP_REGS_OFFS_OFST 8
+#define MC_CMD_FC_OUT_GET_ASSERT_GP_REGS_OFFS_LEN 4
+#define MC_CMD_FC_OUT_GET_ASSERT_GP_REGS_OFFS_NUM 31
+#define MC_CMD_FC_OUT_GET_ASSERT_EXCEPTION_TYPE_OFFS_OFST 132
+#define MC_CMD_FC_OUT_GET_ASSERT_EXCEPTION_PC_ADDR_OFFS_OFST 136
+#define MC_CMD_FC_OUT_GET_ASSERT_EXCEPTION_BAD_ADDR_OFFS_OFST 140
+
+/* MC_CMD_FC_OUT_FPGA_BUILD msgresponse */
+#define MC_CMD_FC_OUT_FPGA_BUILD_LEN 32
+#define MC_CMD_FC_OUT_FPGA_BUILD_COMPONENT_INFO_OFST 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_IS_APPLICATION_LBN 31
+#define MC_CMD_FC_OUT_FPGA_BUILD_IS_APPLICATION_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_IS_LICENSED_LBN 30
+#define MC_CMD_FC_OUT_FPGA_BUILD_IS_LICENSED_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_COMPONENT_ID_LBN 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_COMPONENT_ID_WIDTH 14
+#define MC_CMD_FC_OUT_FPGA_BUILD_VERSION_MAJOR_LBN 12
+#define MC_CMD_FC_OUT_FPGA_BUILD_VERSION_MAJOR_WIDTH 4
+#define MC_CMD_FC_OUT_FPGA_BUILD_VERSION_MINOR_LBN 4
+#define MC_CMD_FC_OUT_FPGA_BUILD_VERSION_MINOR_WIDTH 8
+#define MC_CMD_FC_OUT_FPGA_BUILD_BUILD_NUM_LBN 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_BUILD_NUM_WIDTH 4
+#define MC_CMD_FC_OUT_FPGA_BUILD_TIMESTAMP_OFST 4
+#define MC_CMD_FC_OUT_FPGA_BUILD_PARAMETERS_OFST 8
+#define MC_CMD_FC_OUT_FPGA_BUILD_FPGA_TYPE_LBN 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_FPGA_TYPE_WIDTH 8
+#define MC_CMD_FC_FPGA_TYPE_A7 0xa7 /* enum */
+#define MC_CMD_FC_FPGA_TYPE_A5 0xa5 /* enum */
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED1_LBN 8
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED1_WIDTH 10
+#define MC_CMD_FC_OUT_FPGA_BUILD_PTP_ENABLED_LBN 18
+#define MC_CMD_FC_OUT_FPGA_BUILD_PTP_ENABLED_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM1_RLDRAM_DEF_LBN 19
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM1_RLDRAM_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM2_RLDRAM_DEF_LBN 20
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM2_RLDRAM_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM3_RLDRAM_DEF_LBN 21
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM3_RLDRAM_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM4_RLDRAM_DEF_LBN 22
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM4_RLDRAM_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_T0_DDR3_DEF_LBN 23
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_T0_DDR3_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_T1_DDR3_DEF_LBN 24
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_T1_DDR3_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_B0_DDR3_DEF_LBN 25
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_B0_DDR3_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_B1_DDR3_DEF_LBN 26
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_B1_DDR3_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_DDR3_ECC_ENABLED_LBN 27
+#define MC_CMD_FC_OUT_FPGA_BUILD_DDR3_ECC_ENABLED_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_T1_QDR_DEF_LBN 28
+#define MC_CMD_FC_OUT_FPGA_BUILD_SODIMM_T1_QDR_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED2_LBN 29
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED2_WIDTH 2
+#define MC_CMD_FC_OUT_FPGA_BUILD_CRC_APPEND_LBN 31
+#define MC_CMD_FC_OUT_FPGA_BUILD_CRC_APPEND_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_BUILD_IDENTIFIER_OFST 12
+#define MC_CMD_FC_OUT_FPGA_BUILD_CHANGESET_LBN 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_CHANGESET_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_BUILD_FLAG_LBN 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_BUILD_FLAG_WIDTH 1
+#define MC_CMD_FC_FPGA_BUILD_FLAG_INTERNAL 0x0 /* enum */
+#define MC_CMD_FC_FPGA_BUILD_FLAG_RELEASE 0x1 /* enum */
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED3_LBN 17
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED3_WIDTH 15
+#define MC_CMD_FC_OUT_FPGA_BUILD_VERSION_HI_OFST 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_MINOR_LBN 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_MINOR_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_MAJOR_LBN 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_MAJOR_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_VERSION_LO_OFST 20
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_BUILD_LBN 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_BUILD_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_MICRO_LBN 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_DEPLOYMENT_VERSION_MICRO_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED4_OFST 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED4_LEN 8
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED4_LO_OFST 16
+#define MC_CMD_FC_OUT_FPGA_BUILD_RESERVED4_HI_OFST 20
+#define MC_CMD_FC_OUT_FPGA_BUILD_REVISION_LO_OFST 24
+#define MC_CMD_FC_OUT_FPGA_BUILD_REVISION_HI_OFST 28
+#define MC_CMD_FC_OUT_FPGA_BUILD_REVISION_HIGH_LBN 0
+#define MC_CMD_FC_OUT_FPGA_BUILD_REVISION_HIGH_WIDTH 16
+
+/* MC_CMD_FC_OUT_FPGA_SERVICES msgresponse */
+#define MC_CMD_FC_OUT_FPGA_SERVICES_LEN 32
+#define MC_CMD_FC_OUT_FPGA_SERVICES_COMPONENT_INFO_OFST 0
+#define MC_CMD_FC_OUT_FPGA_SERVICES_IS_APPLICATION_LBN 31
+#define MC_CMD_FC_OUT_FPGA_SERVICES_IS_APPLICATION_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_IS_LICENSED_LBN 30
+#define MC_CMD_FC_OUT_FPGA_SERVICES_IS_LICENSED_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_COMPONENT_ID_LBN 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_COMPONENT_ID_WIDTH 14
+#define MC_CMD_FC_OUT_FPGA_SERVICES_VERSION_MAJOR_LBN 12
+#define MC_CMD_FC_OUT_FPGA_SERVICES_VERSION_MAJOR_WIDTH 4
+#define MC_CMD_FC_OUT_FPGA_SERVICES_VERSION_MINOR_LBN 4
+#define MC_CMD_FC_OUT_FPGA_SERVICES_VERSION_MINOR_WIDTH 8
+#define MC_CMD_FC_OUT_FPGA_SERVICES_BUILD_NUM_LBN 0
+#define MC_CMD_FC_OUT_FPGA_SERVICES_BUILD_NUM_WIDTH 4
+#define MC_CMD_FC_OUT_FPGA_SERVICES_TIMESTAMP_OFST 4
+#define MC_CMD_FC_OUT_FPGA_SERVICES_PARAMETERS_OFST 8
+#define MC_CMD_FC_OUT_FPGA_SERVICES_FC_FLASH_BOOTED_LBN 8
+#define MC_CMD_FC_OUT_FPGA_SERVICES_FC_FLASH_BOOTED_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_NIC0_DEF_LBN 27
+#define MC_CMD_FC_OUT_FPGA_SERVICES_NIC0_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_NIC1_DEF_LBN 28
+#define MC_CMD_FC_OUT_FPGA_SERVICES_NIC1_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_SFP0_DEF_LBN 29
+#define MC_CMD_FC_OUT_FPGA_SERVICES_SFP0_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_SFP1_DEF_LBN 30
+#define MC_CMD_FC_OUT_FPGA_SERVICES_SFP1_DEF_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_RESERVED_LBN 31
+#define MC_CMD_FC_OUT_FPGA_SERVICES_RESERVED_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_IDENTIFIER_OFST 12
+#define MC_CMD_FC_OUT_FPGA_SERVICES_CHANGESET_LBN 0
+#define MC_CMD_FC_OUT_FPGA_SERVICES_CHANGESET_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_BUILD_FLAG_LBN 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_BUILD_FLAG_WIDTH 1
+#define MC_CMD_FC_OUT_FPGA_SERVICES_MEMORY_SIZE_OFST 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_MEMORY_SIZE_WIDTH_LBN 0
+#define MC_CMD_FC_OUT_FPGA_SERVICES_MEMORY_SIZE_WIDTH_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_MEMORY_SIZE_COUNT_LBN 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_MEMORY_SIZE_COUNT_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_INSTANCE_SIZE_OFST 20
+#define MC_CMD_FC_OUT_FPGA_SERVICES_INSTANCE_SIZE_WIDTH_LBN 0
+#define MC_CMD_FC_OUT_FPGA_SERVICES_INSTANCE_SIZE_WIDTH_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_INSTANCE_SIZE_COUNT_LBN 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_INSTANCE_SIZE_COUNT_WIDTH 16
+#define MC_CMD_FC_OUT_FPGA_SERVICES_REVISION_LO_OFST 24
+#define MC_CMD_FC_OUT_FPGA_SERVICES_REVISION_HI_OFST 28
+#define MC_CMD_FC_OUT_FPGA_SERVICES_REVISION_HIGH_LBN 0
+#define MC_CMD_FC_OUT_FPGA_SERVICES_REVISION_HIGH_WIDTH 16
+
+/* MC_CMD_FC_OUT_BSP_VERSION msgresponse */
+#define MC_CMD_FC_OUT_BSP_VERSION_LEN 4
+#define MC_CMD_FC_OUT_BSP_VERSION_SYSID_OFST 0
+#define MC_CMD_FC_OUT_BSP_VERSION_VERSION_MAJOR_LBN 12
+#define MC_CMD_FC_OUT_BSP_VERSION_VERSION_MAJOR_WIDTH 4
+#define MC_CMD_FC_OUT_BSP_VERSION_VERSION_MINOR_LBN 4
+#define MC_CMD_FC_OUT_BSP_VERSION_VERSION_MINOR_WIDTH 8
+#define MC_CMD_FC_OUT_BSP_VERSION_BUILD_NUM_LBN 0
+#define MC_CMD_FC_OUT_BSP_VERSION_BUILD_NUM_WIDTH 4
+
+/* MC_CMD_FC_OUT_READ_MAP_COUNT msgresponse */
+#define MC_CMD_FC_OUT_READ_MAP_COUNT_LEN 4
+#define MC_CMD_FC_OUT_READ_MAP_COUNT_NUM_MAPS_OFST 0
+
+/* MC_CMD_FC_OUT_READ_MAP_INDEX msgresponse */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LEN 164
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_INDEX_OFST 0
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_OPTIONS_OFST 4
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ALIGN_8 0x0 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ALIGN_16 0x1 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ALIGN_32 0x2 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ALIGN_64 0x3 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ALIGN_MASK 0x3 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_PATH_FC 0x4 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_PATH_MEM 0x8 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_PERM_READ 0x10 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_PERM_WRITE 0x20 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LICENSE_FREE 0x0 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LICENSE_LICENSED 0x40 /* enum */
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ADDRESS_OFST 8
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ADDRESS_LEN 8
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ADDRESS_LO_OFST 8
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_ADDRESS_HI_OFST 12
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LEN_OFST 16
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LEN_LEN 8
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LEN_LO_OFST 16
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LEN_HI_OFST 20
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_COMP_INFO_OFST 24
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LICENSE_DATE_OFST 28
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LICENSE_DATE_LEN 8
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LICENSE_DATE_LO_OFST 28
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_LICENSE_DATE_HI_OFST 32
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_NAME_OFST 36
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_NAME_LEN 1
+#define MC_CMD_FC_OUT_READ_MAP_INDEX_NAME_NUM 128
+
+/* MC_CMD_FC_OUT_READ_MAP msgresponse */
+#define MC_CMD_FC_OUT_READ_MAP_LEN 0
+
+/* MC_CMD_FC_OUT_CAPABILITIES msgresponse */
+#define MC_CMD_FC_OUT_CAPABILITIES_LEN 8
+#define MC_CMD_FC_OUT_CAPABILITIES_INTERNAL_OFST 0
+#define MC_CMD_FC_OUT_CAPABILITIES_EXTERNAL_OFST 4
+
+/* MC_CMD_FC_OUT_GLOBAL_FLAGS msgresponse */
+#define MC_CMD_FC_OUT_GLOBAL_FLAGS_LEN 4
+#define MC_CMD_FC_OUT_GLOBAL_FLAGS_FLAGS_OFST 0
+
+/* MC_CMD_FC_OUT_IO_REL msgresponse */
+#define MC_CMD_FC_OUT_IO_REL_LEN 0
+
+/* MC_CMD_FC_OUT_IO_REL_GET_ADDR msgresponse */
+#define MC_CMD_FC_OUT_IO_REL_GET_ADDR_LEN 8
+#define MC_CMD_FC_OUT_IO_REL_GET_ADDR_ADDR_HI_OFST 0
+#define MC_CMD_FC_OUT_IO_REL_GET_ADDR_ADDR_LO_OFST 4
+
+/* MC_CMD_FC_OUT_IO_REL_READ32 msgresponse */
+#define MC_CMD_FC_OUT_IO_REL_READ32_LENMIN 4
+#define MC_CMD_FC_OUT_IO_REL_READ32_LENMAX 252
+#define MC_CMD_FC_OUT_IO_REL_READ32_LEN(num) (0+4*(num))
+#define MC_CMD_FC_OUT_IO_REL_READ32_BUFFER_OFST 0
+#define MC_CMD_FC_OUT_IO_REL_READ32_BUFFER_LEN 4
+#define MC_CMD_FC_OUT_IO_REL_READ32_BUFFER_MINNUM 1
+#define MC_CMD_FC_OUT_IO_REL_READ32_BUFFER_MAXNUM 63
+
+/* MC_CMD_FC_OUT_IO_REL_WRITE32 msgresponse */
+#define MC_CMD_FC_OUT_IO_REL_WRITE32_LEN 0
+
+/* MC_CMD_FC_OUT_UHLINK_PHY msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_PHY_LEN 48
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_SETTINGS_0_OFST 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_VOD_LBN 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_VOD_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_PREEMP_1STPOSTTAP_LBN 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_PREEMP_1STPOSTTAP_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_SETTINGS_1_OFST 4
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_PREEMP_PRETAP_LBN 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_PREEMP_PRETAP_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_PREEMP_2NDPOSTTAP_LBN 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_TX_PREEMP_2NDPOSTTAP_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_RX_SETTINGS_OFST 8
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_RX_DC_GAIN_LBN 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_RX_DC_GAIN_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_RX_EQ_CONTROL_LBN 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_TRC_RX_EQ_CONTROL_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_RX_EYE_OFST 12
+#define MC_CMD_FC_OUT_UHLINK_PHY_RX_EYE_WIDTH_LBN 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_RX_EYE_WIDTH_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_RX_EYE_HEIGHT_LBN 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_RX_EYE_HEIGHT_WIDTH 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_PCS_STATUS_OFST 16
+#define MC_CMD_FC_OUT_UHLINK_PHY_LINK_STATE_WORD_OFST 20
+#define MC_CMD_FC_OUT_UHLINK_PHY_LINK_STATE_LBN 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_LINK_STATE_WIDTH 1
+#define MC_CMD_FC_OUT_UHLINK_PHY_LINK_CONFIGURED_LBN 1
+#define MC_CMD_FC_OUT_UHLINK_PHY_LINK_CONFIGURED_WIDTH 1
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_PARAMS_OFST 24
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_PARAMS_LEN 20
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_SPEED_OFST 24
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_COPPER_LEN_OFST 28
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_DUAL_SPEED_OFST 32
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_PRESENT_OFST 36
+#define MC_CMD_FC_OUT_UHLINK_PHY_SFP_TYPE_OFST 40
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_OFST 44
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_DFE_LBN 0
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_DFE_WIDTH 1
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_AEQ_LBN 1
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_AEQ_WIDTH 1
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_RX_TUNING_LBN 2
+#define MC_CMD_FC_OUT_UHLINK_PHY_PHY_CFG_RX_TUNING_WIDTH 1
+
+/* MC_CMD_FC_OUT_UHLINK_MAC msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_MAC_LEN 20
+#define MC_CMD_FC_OUT_UHLINK_MAC_CONFIG_OFST 0
+#define MC_CMD_FC_OUT_UHLINK_MAC_MTU_OFST 4
+#define MC_CMD_FC_OUT_UHLINK_MAC_IF_STATUS_OFST 8
+#define MC_CMD_FC_OUT_UHLINK_MAC_ADDR_OFST 12
+#define MC_CMD_FC_OUT_UHLINK_MAC_ADDR_LEN 8
+#define MC_CMD_FC_OUT_UHLINK_MAC_ADDR_LO_OFST 12
+#define MC_CMD_FC_OUT_UHLINK_MAC_ADDR_HI_OFST 16
+
+/* MC_CMD_FC_OUT_UHLINK_RX_EYE msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_RX_EYE_LEN ((((0-1+(32*MC_CMD_FC_UHLINK_RX_EYE_PER_BLOCK))+1))>>3)
+#define MC_CMD_FC_OUT_UHLINK_RX_EYE_RX_EYE_OFST 0
+#define MC_CMD_FC_OUT_UHLINK_RX_EYE_RX_EYE_LEN 4
+#define MC_CMD_FC_OUT_UHLINK_RX_EYE_RX_EYE_NUM MC_CMD_FC_UHLINK_RX_EYE_PER_BLOCK
+
+/* MC_CMD_FC_OUT_UHLINK_DUMP_RX_EYE_PLOT msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_DUMP_RX_EYE_PLOT_LEN 0
+
+/* MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_LEN ((((32-1+(64*MC_CMD_FC_UHLINK_RX_EYE_PLOT_ROWS_PER_BLOCK))+1))>>3)
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_VALID_OFST 0
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_ROWS_OFST 4
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_ROWS_LEN 8
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_ROWS_LO_OFST 4
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_ROWS_HI_OFST 8
+#define MC_CMD_FC_OUT_UHLINK_READ_RX_EYE_PLOT_ROWS_NUM MC_CMD_FC_UHLINK_RX_EYE_PLOT_ROWS_PER_BLOCK
+
+/* MC_CMD_FC_OUT_UHLINK_RX_TUNE msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_RX_TUNE_LEN 0
+
+/* MC_CMD_FC_OUT_UHLINK_LOOPBACK_SET msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_LOOPBACK_SET_LEN 0
+
+/* MC_CMD_FC_OUT_UHLINK_LOOPBACK_GET msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_LOOPBACK_GET_LEN 4
+#define MC_CMD_FC_OUT_UHLINK_LOOPBACK_GET_STATE_OFST 0
+
+/* MC_CMD_FC_OUT_UHLINK msgresponse */
+#define MC_CMD_FC_OUT_UHLINK_LEN 0
+
+/* MC_CMD_FC_OUT_SET_LINK msgresponse */
+#define MC_CMD_FC_OUT_SET_LINK_LEN 0
+
+/* MC_CMD_FC_OUT_LICENSE msgresponse */
+#define MC_CMD_FC_OUT_LICENSE_LEN 12
+#define MC_CMD_FC_OUT_LICENSE_VALID_KEYS_OFST 0
+#define MC_CMD_FC_OUT_LICENSE_INVALID_KEYS_OFST 4
+#define MC_CMD_FC_OUT_LICENSE_BLACKLISTED_KEYS_OFST 8
+
+/* MC_CMD_FC_OUT_STARTUP msgresponse */
+#define MC_CMD_FC_OUT_STARTUP_LEN 4
+#define MC_CMD_FC_OUT_STARTUP_CAPABILITIES_OFST 0
+#define MC_CMD_FC_OUT_STARTUP_CAN_ACCESS_FLASH_LBN 0
+#define MC_CMD_FC_OUT_STARTUP_CAN_ACCESS_FLASH_WIDTH 1
+
+/* MC_CMD_FC_OUT_DMA_READ msgresponse */
+#define MC_CMD_FC_OUT_DMA_READ_LENMIN 1
+#define MC_CMD_FC_OUT_DMA_READ_LENMAX 252
+#define MC_CMD_FC_OUT_DMA_READ_LEN(num) (0+1*(num))
+#define MC_CMD_FC_OUT_DMA_READ_DATA_OFST 0
+#define MC_CMD_FC_OUT_DMA_READ_DATA_LEN 1
+#define MC_CMD_FC_OUT_DMA_READ_DATA_MINNUM 1
+#define MC_CMD_FC_OUT_DMA_READ_DATA_MAXNUM 252
+
+/* MC_CMD_FC_OUT_TIMED_READ_SET msgresponse */
+#define MC_CMD_FC_OUT_TIMED_READ_SET_LEN 4
+#define MC_CMD_FC_OUT_TIMED_READ_SET_FC_HANDLE_OFST 0
+
+/* MC_CMD_FC_OUT_TIMED_READ_GET msgresponse */
+#define MC_CMD_FC_OUT_TIMED_READ_GET_LEN 52
+#define MC_CMD_FC_OUT_TIMED_READ_GET_HOST_HANDLE_OFST 0
+#define MC_CMD_FC_OUT_TIMED_READ_GET_HOST_DMA_ADDRESS_OFST 4
+#define MC_CMD_FC_OUT_TIMED_READ_GET_HOST_DMA_ADDRESS_LEN 8
+#define MC_CMD_FC_OUT_TIMED_READ_GET_HOST_DMA_ADDRESS_LO_OFST 4
+#define MC_CMD_FC_OUT_TIMED_READ_GET_HOST_DMA_ADDRESS_HI_OFST 8
+#define MC_CMD_FC_OUT_TIMED_READ_GET_AOE_ADDRESS_OFST 12
+#define MC_CMD_FC_OUT_TIMED_READ_GET_AOE_ADDRESS_LEN 8
+#define MC_CMD_FC_OUT_TIMED_READ_GET_AOE_ADDRESS_LO_OFST 12
+#define MC_CMD_FC_OUT_TIMED_READ_GET_AOE_ADDRESS_HI_OFST 16
+#define MC_CMD_FC_OUT_TIMED_READ_GET_AOE_LENGTH_OFST 20
+#define MC_CMD_FC_OUT_TIMED_READ_GET_HOST_LENGTH_OFST 24
+#define MC_CMD_FC_OUT_TIMED_READ_GET_FLAGS_OFST 28
+#define MC_CMD_FC_OUT_TIMED_READ_GET_PERIOD_OFST 32
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_START_OFST 36
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_START_LEN 8
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_START_LO_OFST 36
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_START_HI_OFST 40
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_END_OFST 44
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_END_LEN 8
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_END_LO_OFST 44
+#define MC_CMD_FC_OUT_TIMED_READ_GET_CLOCK_END_HI_OFST 48
+
+/* MC_CMD_FC_OUT_LOG_ADDR_RANGE msgresponse */
+#define MC_CMD_FC_OUT_LOG_ADDR_RANGE_LEN 0
+
+/* MC_CMD_FC_OUT_LOG msgresponse */
+#define MC_CMD_FC_OUT_LOG_LEN 0
+
+/* MC_CMD_FC_OUT_CLOCK_GET_TIME msgresponse */
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_LEN 24
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_CLOCK_ID_OFST 0
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_SECONDS_OFST 4
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_SECONDS_LEN 8
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_SECONDS_LO_OFST 4
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_SECONDS_HI_OFST 8
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_NANOSECONDS_OFST 12
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_RANGE_OFST 16
+#define MC_CMD_FC_OUT_CLOCK_GET_TIME_PRECISION_OFST 20
+
+/* MC_CMD_FC_OUT_CLOCK_SET_TIME msgresponse */
+#define MC_CMD_FC_OUT_CLOCK_SET_TIME_LEN 0
+
+/* MC_CMD_FC_OUT_DDR_SET_SPD msgresponse */
+#define MC_CMD_FC_OUT_DDR_SET_SPD_LEN 0
+
+/* MC_CMD_FC_OUT_DDR_GET_STATUS msgresponse */
+#define MC_CMD_FC_OUT_DDR_GET_STATUS_LEN 4
+#define MC_CMD_FC_OUT_DDR_GET_STATUS_FLAGS_OFST 0
+#define MC_CMD_FC_OUT_DDR_GET_STATUS_READY_LBN 0
+#define MC_CMD_FC_OUT_DDR_GET_STATUS_READY_WIDTH 1
+#define MC_CMD_FC_OUT_DDR_GET_STATUS_CALIBRATED_LBN 1
+#define MC_CMD_FC_OUT_DDR_GET_STATUS_CALIBRATED_WIDTH 1
+
+/* MC_CMD_FC_OUT_TIMESTAMP_READ_TRANSMIT msgresponse */
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_TRANSMIT_LEN 8
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_TRANSMIT_SECONDS_OFST 0
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_TRANSMIT_NANOSECONDS_OFST 4
+
+/* MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT msgresponse */
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_LENMIN 8
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_LENMAX 248
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_LEN(num) (0+8*(num))
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_SECONDS_OFST 0
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_NANOSECONDS_OFST 4
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_TIMESTAMP_OFST 0
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_TIMESTAMP_LEN 8
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_TIMESTAMP_LO_OFST 0
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_TIMESTAMP_HI_OFST 4
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_TIMESTAMP_MINNUM 0
+#define MC_CMD_FC_OUT_TIMESTAMP_READ_SNAPSHOT_TIMESTAMP_MAXNUM 31
+
+/* MC_CMD_FC_OUT_SPI_READ msgresponse */
+#define MC_CMD_FC_OUT_SPI_READ_LENMIN 4
+#define MC_CMD_FC_OUT_SPI_READ_LENMAX 252
+#define MC_CMD_FC_OUT_SPI_READ_LEN(num) (0+4*(num))
+#define MC_CMD_FC_OUT_SPI_READ_BUFFER_OFST 0
+#define MC_CMD_FC_OUT_SPI_READ_BUFFER_LEN 4
+#define MC_CMD_FC_OUT_SPI_READ_BUFFER_MINNUM 1
+#define MC_CMD_FC_OUT_SPI_READ_BUFFER_MAXNUM 63
+
+/* MC_CMD_FC_OUT_SPI_WRITE msgresponse */
+#define MC_CMD_FC_OUT_SPI_WRITE_LEN 0
+
+/* MC_CMD_FC_OUT_SPI_ERASE msgresponse */
+#define MC_CMD_FC_OUT_SPI_ERASE_LEN 0
+
+/* MC_CMD_FC_OUT_DIAG_POWER_NOISE_READ_CONFIG msgresponse */
+#define MC_CMD_FC_OUT_DIAG_POWER_NOISE_READ_CONFIG_LEN 8
+#define MC_CMD_FC_OUT_DIAG_POWER_NOISE_READ_CONFIG_TOGGLE_COUNT_OFST 0
+#define MC_CMD_FC_OUT_DIAG_POWER_NOISE_READ_CONFIG_CLKEN_COUNT_OFST 4
+
+/* MC_CMD_FC_OUT_DIAG_POWER_NOISE_WRITE_CONFIG msgresponse */
+#define MC_CMD_FC_OUT_DIAG_POWER_NOISE_WRITE_CONFIG_LEN 0
+
+/* MC_CMD_FC_OUT_DIAG_DDR_SOAK_START msgresponse */
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_START_LEN 0
+
+/* MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT msgresponse */
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_LEN 8
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_STATUS_OFST 0
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_PASSED_LBN 0
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_PASSED_WIDTH 1
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_FAILED_LBN 1
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_FAILED_WIDTH 1
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_COMPLETED_LBN 2
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_COMPLETED_WIDTH 1
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_TIMEOUT_LBN 3
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_TIMEOUT_WIDTH 1
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_PNF_LBN 4
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_PNF_WIDTH 1
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_RESULT_ERR_COUNT_OFST 4
+
+/* MC_CMD_FC_OUT_DIAG_DDR_SOAK_STOP msgresponse */
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_STOP_LEN 0
+
+/* MC_CMD_FC_OUT_DIAG_DDR_SOAK_ERROR msgresponse */
+#define MC_CMD_FC_OUT_DIAG_DDR_SOAK_ERROR_LEN 0
+
+/* MC_CMD_FC_OUT_DIAG_DATAPATH_CTRL_SET_MODE msgresponse */
+#define MC_CMD_FC_OUT_DIAG_DATAPATH_CTRL_SET_MODE_LEN 0
+
+/* MC_CMD_FC_OUT_DIAG_DATAPATH_CTRL_RAW_CONFIG msgresponse */
+#define MC_CMD_FC_OUT_DIAG_DATAPATH_CTRL_RAW_CONFIG_LEN 0
+
+
+/***********************************/
+/* MC_CMD_AOE
+ * AOE operations (on MC rather than FC)
+ */
+#define MC_CMD_AOE 0xa
+
+/* MC_CMD_AOE_IN msgrequest */
+#define MC_CMD_AOE_IN_LEN 4
+#define MC_CMD_AOE_IN_OP_HDR_OFST 0
+#define MC_CMD_AOE_IN_OP_LBN 0
+#define MC_CMD_AOE_IN_OP_WIDTH 8
+#define MC_CMD_AOE_OP_INFO 0x1 /* enum */
+#define MC_CMD_AOE_OP_CURRENTS 0x2 /* enum */
+#define MC_CMD_AOE_OP_TEMPERATURES 0x3 /* enum */
+#define MC_CMD_AOE_OP_CPLD_IDLE 0x4 /* enum */
+#define MC_CMD_AOE_OP_CPLD_READ 0x5 /* enum */
+#define MC_CMD_AOE_OP_CPLD_WRITE 0x6 /* enum */
+#define MC_CMD_AOE_OP_CPLD_INSTRUCTION 0x7 /* enum */
+#define MC_CMD_AOE_OP_CPLD_REPROGRAM 0x8 /* enum */
+#define MC_CMD_AOE_OP_POWER 0x9 /* enum */
+#define MC_CMD_AOE_OP_LOAD 0xa /* enum */
+#define MC_CMD_AOE_OP_FAN_CONTROL 0xb /* enum */
+#define MC_CMD_AOE_OP_FAN_FAILURES 0xc /* enum */
+#define MC_CMD_AOE_OP_MAC_STATS 0xd /* enum */
+#define MC_CMD_AOE_OP_GET_PHY_MEDIA_INFO 0xe /* enum */
+#define MC_CMD_AOE_OP_JTAG_WRITE 0xf /* enum */
+#define MC_CMD_AOE_OP_FPGA_ACCESS 0x10 /* enum */
+#define MC_CMD_AOE_OP_SET_MTU_OFFSET 0x11 /* enum */
+#define MC_CMD_AOE_OP_LINK_STATE 0x12 /* enum */
+#define MC_CMD_AOE_OP_SIENA_STATS 0x13 /* enum */
+#define MC_CMD_AOE_OP_DDR 0x14 /* enum */
+#define MC_CMD_AOE_OP_FC 0x15 /* enum */
+#define MC_CMD_AOE_OP_DDR_ECC_STATUS 0x16 /* enum */
+#define MC_CMD_AOE_OP_MC_SPI_MASTER 0x17 /* enum */
+
+/* MC_CMD_AOE_OUT msgresponse */
+#define MC_CMD_AOE_OUT_LEN 0
+
+/* MC_CMD_AOE_IN_INFO msgrequest */
+#define MC_CMD_AOE_IN_INFO_LEN 4
+#define MC_CMD_AOE_IN_CMD_OFST 0
+
+/* MC_CMD_AOE_IN_CURRENTS msgrequest */
+#define MC_CMD_AOE_IN_CURRENTS_LEN 4
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+
+/* MC_CMD_AOE_IN_TEMPERATURES msgrequest */
+#define MC_CMD_AOE_IN_TEMPERATURES_LEN 4
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+
+/* MC_CMD_AOE_IN_CPLD_IDLE msgrequest */
+#define MC_CMD_AOE_IN_CPLD_IDLE_LEN 4
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+
+/* MC_CMD_AOE_IN_CPLD_READ msgrequest */
+#define MC_CMD_AOE_IN_CPLD_READ_LEN 12
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_CPLD_READ_REGISTER_OFST 4
+#define MC_CMD_AOE_IN_CPLD_READ_WIDTH_OFST 8
+
+/* MC_CMD_AOE_IN_CPLD_WRITE msgrequest */
+#define MC_CMD_AOE_IN_CPLD_WRITE_LEN 16
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_CPLD_WRITE_REGISTER_OFST 4
+#define MC_CMD_AOE_IN_CPLD_WRITE_WIDTH_OFST 8
+#define MC_CMD_AOE_IN_CPLD_WRITE_VALUE_OFST 12
+
+/* MC_CMD_AOE_IN_CPLD_INSTRUCTION msgrequest */
+#define MC_CMD_AOE_IN_CPLD_INSTRUCTION_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_CPLD_INSTRUCTION_INSTRUCTION_OFST 4
+
+/* MC_CMD_AOE_IN_CPLD_REPROGRAM msgrequest */
+#define MC_CMD_AOE_IN_CPLD_REPROGRAM_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_CPLD_REPROGRAM_OP_OFST 4
+#define MC_CMD_AOE_IN_CPLD_REPROGRAM_REPROGRAM 0x1 /* enum */
+#define MC_CMD_AOE_IN_CPLD_REPROGRAM_REPROGRAM_EVENT 0x3 /* enum */
+#define MC_CMD_AOE_IN_CPLD_REPROGRAM_STATUS 0x4 /* enum */
+
+/* MC_CMD_AOE_IN_POWER msgrequest */
+#define MC_CMD_AOE_IN_POWER_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_POWER_OP_OFST 4
+#define MC_CMD_AOE_IN_POWER_OFF 0x0 /* enum */
+#define MC_CMD_AOE_IN_POWER_ON 0x1 /* enum */
+#define MC_CMD_AOE_IN_POWER_CLEAR 0x2 /* enum */
+#define MC_CMD_AOE_IN_POWER_SHOW_CURRENT 0x3 /* enum */
+#define MC_CMD_AOE_IN_POWER_SHOW_PEAK 0x4 /* enum */
+#define MC_CMD_AOE_IN_POWER_DDR_LAST 0x5 /* enum */
+#define MC_CMD_AOE_IN_POWER_DDR_PEAK 0x6 /* enum */
+#define MC_CMD_AOE_IN_POWER_DDR_CLEAR 0x7 /* enum */
+
+/* MC_CMD_AOE_IN_LOAD msgrequest */
+#define MC_CMD_AOE_IN_LOAD_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_LOAD_IMAGE_OFST 4
+
+/* MC_CMD_AOE_IN_FAN_CONTROL msgrequest */
+#define MC_CMD_AOE_IN_FAN_CONTROL_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_FAN_CONTROL_REAL_RPM_OFST 4
+
+/* MC_CMD_AOE_IN_FAN_FAILURES msgrequest */
+#define MC_CMD_AOE_IN_FAN_FAILURES_LEN 4
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+
+/* MC_CMD_AOE_IN_MAC_STATS msgrequest */
+#define MC_CMD_AOE_IN_MAC_STATS_LEN 24
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_MAC_STATS_PORT_OFST 4
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_ADDR_OFST 8
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_ADDR_LEN 8
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_ADDR_LO_OFST 8
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_ADDR_HI_OFST 12
+#define MC_CMD_AOE_IN_MAC_STATS_CMD_OFST 16
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_LBN 0
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_WIDTH 1
+#define MC_CMD_AOE_IN_MAC_STATS_CLEAR_LBN 1
+#define MC_CMD_AOE_IN_MAC_STATS_CLEAR_WIDTH 1
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_CHANGE_LBN 2
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_CHANGE_WIDTH 1
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_ENABLE_LBN 3
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_ENABLE_WIDTH 1
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_CLEAR_LBN 4
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_CLEAR_WIDTH 1
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_NOEVENT_LBN 5
+#define MC_CMD_AOE_IN_MAC_STATS_PERIODIC_NOEVENT_WIDTH 1
+#define MC_CMD_AOE_IN_MAC_STATS_PERIOD_MS_LBN 16
+#define MC_CMD_AOE_IN_MAC_STATS_PERIOD_MS_WIDTH 16
+#define MC_CMD_AOE_IN_MAC_STATS_DMA_LEN_OFST 20
+
+/* MC_CMD_AOE_IN_GET_PHY_MEDIA_INFO msgrequest */
+#define MC_CMD_AOE_IN_GET_PHY_MEDIA_INFO_LEN 12
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_GET_PHY_MEDIA_INFO_PORT_OFST 4
+#define MC_CMD_AOE_IN_GET_PHY_MEDIA_INFO_PAGE_OFST 8
+
+/* MC_CMD_AOE_IN_JTAG_WRITE msgrequest */
+#define MC_CMD_AOE_IN_JTAG_WRITE_LENMIN 12
+#define MC_CMD_AOE_IN_JTAG_WRITE_LENMAX 252
+#define MC_CMD_AOE_IN_JTAG_WRITE_LEN(num) (8+4*(num))
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_JTAG_WRITE_DATALEN_OFST 4
+#define MC_CMD_AOE_IN_JTAG_WRITE_DATA_OFST 8
+#define MC_CMD_AOE_IN_JTAG_WRITE_DATA_LEN 4
+#define MC_CMD_AOE_IN_JTAG_WRITE_DATA_MINNUM 1
+#define MC_CMD_AOE_IN_JTAG_WRITE_DATA_MAXNUM 61
+
+/* MC_CMD_AOE_IN_FPGA_ACCESS msgrequest */
+#define MC_CMD_AOE_IN_FPGA_ACCESS_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_FPGA_ACCESS_OP_OFST 4
+#define MC_CMD_AOE_IN_FPGA_ACCESS_ENABLE 0x1 /* enum */
+#define MC_CMD_AOE_IN_FPGA_ACCESS_DISABLE 0x2 /* enum */
+
+/* MC_CMD_AOE_IN_SET_MTU_OFFSET msgrequest */
+#define MC_CMD_AOE_IN_SET_MTU_OFFSET_LEN 12
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_SET_MTU_OFFSET_PORT_OFST 4
+#define MC_CMD_AOE_IN_SET_MTU_OFFSET_ALL_EXTERNAL 0x8000 /* enum */
+#define MC_CMD_AOE_IN_SET_MTU_OFFSET_ALL_INTERNAL 0x4000 /* enum */
+#define MC_CMD_AOE_IN_SET_MTU_OFFSET_OFFSET_OFST 8
+
+/* MC_CMD_AOE_IN_LINK_STATE msgrequest */
+#define MC_CMD_AOE_IN_LINK_STATE_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_LINK_STATE_MODE_OFST 4
+#define MC_CMD_AOE_IN_LINK_STATE_CONFIG_MODE_LBN 0
+#define MC_CMD_AOE_IN_LINK_STATE_CONFIG_MODE_WIDTH 8
+#define MC_CMD_AOE_IN_LINK_STATE_SIMPLE_SEPARATE 0x0 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_SIMPLE_COMBINED 0x1 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_DIAGNOSTIC 0x2 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_CUSTOM 0x3 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_OPERATION_LBN 8
+#define MC_CMD_AOE_IN_LINK_STATE_OPERATION_WIDTH 8
+#define MC_CMD_AOE_IN_LINK_STATE_OP_NONE 0x0 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_OP_OR 0x1 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_OP_AND 0x2 /* enum */
+#define MC_CMD_AOE_IN_LINK_STATE_SFP_MASK_LBN 16
+#define MC_CMD_AOE_IN_LINK_STATE_SFP_MASK_WIDTH 16
+
+/* MC_CMD_AOE_IN_SIENA_STATS msgrequest */
+#define MC_CMD_AOE_IN_SIENA_STATS_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_SIENA_STATS_MODE_OFST 4
+#define MC_CMD_AOE_IN_SIENA_STATS_STATS_SIENA 0x0 /* enum */
+#define MC_CMD_AOE_IN_SIENA_STATS_STATS_AOE 0x1 /* enum */
+
+/* MC_CMD_AOE_IN_DDR msgrequest */
+#define MC_CMD_AOE_IN_DDR_LEN 12
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_DDR_BANK_OFST 4
+/* Enum values, see field(s): */
+/* MC_CMD_FC_IN_DDR_BANK */
+#define MC_CMD_AOE_IN_DDR_SPD_PAGE_ID_OFST 8
+
+/* MC_CMD_AOE_IN_FC msgrequest */
+#define MC_CMD_AOE_IN_FC_LEN 4
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+
+/* MC_CMD_AOE_IN_DDR_ECC_STATUS msgrequest */
+#define MC_CMD_AOE_IN_DDR_ECC_STATUS_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_DDR_ECC_STATUS_BANK_OFST 4
+/* Enum values, see field(s): */
+/* MC_CMD_FC_IN_DDR_BANK */
+
+/* MC_CMD_AOE_IN_MC_SPI_MASTER msgrequest */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_LEN 8
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_OP_OFST 4
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_READ 0x0 /* enum */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_WRITE 0x1 /* enum */
+
+/* MC_CMD_AOE_IN_MC_SPI_MASTER_READ msgrequest */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_READ_LEN 12
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_READ_OP_OFST 4
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_READ_OFFSET_OFST 8
+
+/* MC_CMD_AOE_IN_MC_SPI_MASTER_WRITE msgrequest */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_WRITE_LEN 16
+/* MC_CMD_AOE_IN_CMD_OFST 0 */
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_WRITE_OP_OFST 4
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_WRITE_OFFSET_OFST 8
+#define MC_CMD_AOE_IN_MC_SPI_MASTER_WRITE_DATA_OFST 12
+
+/* MC_CMD_AOE_OUT_INFO msgresponse */
+#define MC_CMD_AOE_OUT_INFO_LEN 44
+#define MC_CMD_AOE_OUT_INFO_CPLD_IDCODE_OFST 0
+#define MC_CMD_AOE_OUT_INFO_CPLD_VERSION_OFST 4
+#define MC_CMD_AOE_OUT_INFO_FPGA_IDCODE_OFST 8
+#define MC_CMD_AOE_OUT_INFO_FPGA_VERSION_OFST 12
+#define MC_CMD_AOE_OUT_INFO_FPGA_TYPE_OFST 16
+#define MC_CMD_AOE_OUT_INFO_FPGA_STATE_OFST 20
+#define MC_CMD_AOE_OUT_INFO_FPGA_IMAGE_OFST 24
+#define MC_CMD_AOE_OUT_INFO_FC_STATE_OFST 28
+#define MC_CMD_AOE_OUT_INFO_WATCHDOG 0x1 /* enum */
+#define MC_CMD_AOE_OUT_INFO_COMMS 0x2 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FLAGS_OFST 32
+#define MC_CMD_AOE_OUT_INFO_PEG_POWER 0x1 /* enum */
+#define MC_CMD_AOE_OUT_INFO_CPLD_GOOD 0x2 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FPGA_GOOD 0x4 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FPGA_POWER 0x8 /* enum */
+#define MC_CMD_AOE_OUT_INFO_BAD_SODIMM 0x10 /* enum */
+#define MC_CMD_AOE_OUT_INFO_HAS_BYTEBLASTER 0x20 /* enum */
+#define MC_CMD_AOE_OUT_INFO_BOARD_REVISION_OFST 36
+#define MC_CMD_AOE_OUT_INFO_UNKNOWN 0x0 /* enum */
+#define MC_CMD_AOE_OUT_INFO_R1_0 0x10 /* enum */
+#define MC_CMD_AOE_OUT_INFO_R1_1 0x11 /* enum */
+#define MC_CMD_AOE_OUT_INFO_R1_2 0x12 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_RESULT_OFST 40
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_FAIL_NO_ERROR 0x0 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_FAIL_BAD_ADDRESS 0x1 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_FAIL_BAD_MAGIC 0x2 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_FAIL_BAD_TEXT 0x3 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_FAIL_BAD_CHECKSUM 0x4 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_FAIL_BAD_BSP 0x5 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_APP_EXECUTE 0x80 /* enum */
+#define MC_CMD_AOE_OUT_INFO_FC_BOOT_NO_BOOTROM 0xff /* enum */
+
+/* MC_CMD_AOE_OUT_CURRENTS msgresponse */
+#define MC_CMD_AOE_OUT_CURRENTS_LEN 68
+#define MC_CMD_AOE_OUT_CURRENTS_VALUES_OFST 0
+#define MC_CMD_AOE_OUT_CURRENTS_VALUES_LEN 4
+#define MC_CMD_AOE_OUT_CURRENTS_VALUES_NUM 17
+#define MC_CMD_AOE_OUT_CURRENTS_I_2V5 0x0 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_1V8 0x1 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_GXB 0x2 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_PGM 0x3 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_XCVR 0x4 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_1V5 0x5 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_V_3V3 0x6 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_V_1V5 0x7 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_IN 0x8 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_OUT 0x9 /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_V_IN 0xa /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_OUT_DDR1 0xb /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_V_OUT_DDR1 0xc /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_OUT_DDR2 0xd /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_V_OUT_DDR2 0xe /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_I_OUT_DDR3 0xf /* enum */
+#define MC_CMD_AOE_OUT_CURRENTS_V_OUT_DDR3 0x10 /* enum */
+
+/* MC_CMD_AOE_OUT_TEMPERATURES msgresponse */
+#define MC_CMD_AOE_OUT_TEMPERATURES_LEN 40
+#define MC_CMD_AOE_OUT_TEMPERATURES_VALUES_OFST 0
+#define MC_CMD_AOE_OUT_TEMPERATURES_VALUES_LEN 4
+#define MC_CMD_AOE_OUT_TEMPERATURES_VALUES_NUM 10
+#define MC_CMD_AOE_OUT_TEMPERATURES_MAIN_0 0x0 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_MAIN_1 0x1 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_IND_0 0x2 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_IND_1 0x3 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_VCCIO1 0x4 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_VCCIO2 0x5 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_VCCIO3 0x6 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_PSU 0x7 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_FPGA 0x8 /* enum */
+#define MC_CMD_AOE_OUT_TEMPERATURES_SIENA 0x9 /* enum */
+
+/* MC_CMD_AOE_OUT_CPLD_READ msgresponse */
+#define MC_CMD_AOE_OUT_CPLD_READ_LEN 4
+#define MC_CMD_AOE_OUT_CPLD_READ_VALUE_OFST 0
+
+/* MC_CMD_AOE_OUT_FAN_FAILURES msgresponse */
+#define MC_CMD_AOE_OUT_FAN_FAILURES_LENMIN 4
+#define MC_CMD_AOE_OUT_FAN_FAILURES_LENMAX 252
+#define MC_CMD_AOE_OUT_FAN_FAILURES_LEN(num) (0+4*(num))
+#define MC_CMD_AOE_OUT_FAN_FAILURES_COUNT_OFST 0
+#define MC_CMD_AOE_OUT_FAN_FAILURES_COUNT_LEN 4
+#define MC_CMD_AOE_OUT_FAN_FAILURES_COUNT_MINNUM 1
+#define MC_CMD_AOE_OUT_FAN_FAILURES_COUNT_MAXNUM 63
+
+/* MC_CMD_AOE_OUT_CPLD_REPROGRAM msgresponse */
+#define MC_CMD_AOE_OUT_CPLD_REPROGRAM_LEN 4
+#define MC_CMD_AOE_OUT_CPLD_REPROGRAM_STATUS_OFST 0
+
+/* MC_CMD_AOE_OUT_MAC_STATS_DMA msgresponse */
+#define MC_CMD_AOE_OUT_MAC_STATS_DMA_LEN 0
+
+/* MC_CMD_AOE_OUT_MAC_STATS_NO_DMA msgresponse */
+#define MC_CMD_AOE_OUT_MAC_STATS_NO_DMA_LEN (((MC_CMD_MAC_NSTATS*64))>>3)
+#define MC_CMD_AOE_OUT_MAC_STATS_NO_DMA_STATISTICS_OFST 0
+#define MC_CMD_AOE_OUT_MAC_STATS_NO_DMA_STATISTICS_LEN 8
+#define MC_CMD_AOE_OUT_MAC_STATS_NO_DMA_STATISTICS_LO_OFST 0
+#define MC_CMD_AOE_OUT_MAC_STATS_NO_DMA_STATISTICS_HI_OFST 4
+#define MC_CMD_AOE_OUT_MAC_STATS_NO_DMA_STATISTICS_NUM MC_CMD_MAC_NSTATS
+
+/* MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO msgresponse */
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_LENMIN 5
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_LENMAX 252
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_LEN(num) (4+1*(num))
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_DATALEN_OFST 0
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_DATA_OFST 4
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_DATA_LEN 1
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_DATA_MINNUM 1
+#define MC_CMD_AOE_OUT_GET_PHY_MEDIA_INFO_DATA_MAXNUM 248
+
+/* MC_CMD_AOE_OUT_JTAG_WRITE msgresponse */
+#define MC_CMD_AOE_OUT_JTAG_WRITE_LENMIN 12
+#define MC_CMD_AOE_OUT_JTAG_WRITE_LENMAX 252
+#define MC_CMD_AOE_OUT_JTAG_WRITE_LEN(num) (8+4*(num))
+#define MC_CMD_AOE_OUT_JTAG_WRITE_DATALEN_OFST 0
+#define MC_CMD_AOE_OUT_JTAG_WRITE_PAD_OFST 4
+#define MC_CMD_AOE_OUT_JTAG_WRITE_DATA_OFST 8
+#define MC_CMD_AOE_OUT_JTAG_WRITE_DATA_LEN 4
+#define MC_CMD_AOE_OUT_JTAG_WRITE_DATA_MINNUM 1
+#define MC_CMD_AOE_OUT_JTAG_WRITE_DATA_MAXNUM 61
+
+/* MC_CMD_AOE_OUT_FPGA_ACCESS msgresponse */
+#define MC_CMD_AOE_OUT_FPGA_ACCESS_LEN 0
+
+/* MC_CMD_AOE_OUT_DDR msgresponse */
+#define MC_CMD_AOE_OUT_DDR_LENMIN 17
+#define MC_CMD_AOE_OUT_DDR_LENMAX 252
+#define MC_CMD_AOE_OUT_DDR_LEN(num) (16+1*(num))
+#define MC_CMD_AOE_OUT_DDR_FLAGS_OFST 0
+#define MC_CMD_AOE_OUT_DDR_PRESENT_LBN 0
+#define MC_CMD_AOE_OUT_DDR_PRESENT_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_POWERED_LBN 1
+#define MC_CMD_AOE_OUT_DDR_POWERED_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_OPERATIONAL_LBN 2
+#define MC_CMD_AOE_OUT_DDR_OPERATIONAL_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_CAPACITY_OFST 4
+#define MC_CMD_AOE_OUT_DDR_TYPE_OFST 8
+#define MC_CMD_AOE_OUT_DDR_VOLTAGE_OFST 12
+#define MC_CMD_AOE_OUT_DDR_SPD_OFST 16
+#define MC_CMD_AOE_OUT_DDR_SPD_LEN 1
+#define MC_CMD_AOE_OUT_DDR_SPD_MINNUM 1
+#define MC_CMD_AOE_OUT_DDR_SPD_MAXNUM 236
+
+/* MC_CMD_AOE_OUT_LINK_STATE msgresponse */
+#define MC_CMD_AOE_OUT_LINK_STATE_LEN 0
+
+/* MC_CMD_AOE_OUT_FC msgresponse */
+#define MC_CMD_AOE_OUT_FC_LEN 0
+
+/* MC_CMD_AOE_OUT_DDR_ECC_STATUS msgresponse */
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_LEN 8
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_FLAGS_OFST 0
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_VALID_LBN 0
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_VALID_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_STATUS_OFST 4
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_SBE_LBN 0
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_SBE_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_DBE_LBN 1
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_DBE_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_CORDROP_LBN 2
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_CORDROP_WIDTH 1
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_SBE_COUNT_LBN 8
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_SBE_COUNT_WIDTH 8
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_DBE_COUNT_LBN 16
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_DBE_COUNT_WIDTH 8
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_CORDROP_COUNT_LBN 24
+#define MC_CMD_AOE_OUT_DDR_ECC_STATUS_CORDROP_COUNT_WIDTH 8
+
+/* MC_CMD_AOE_OUT_MC_SPI_MASTER_READ msgresponse */
+#define MC_CMD_AOE_OUT_MC_SPI_MASTER_READ_LEN 4
+#define MC_CMD_AOE_OUT_MC_SPI_MASTER_READ_DATA_OFST 0
+
+/* MC_CMD_AOE_OUT_MC_SPI_MASTER_WRITE msgresponse */
+#define MC_CMD_AOE_OUT_MC_SPI_MASTER_WRITE_LEN 0
+
+/* MC_CMD_AOE_OUT_MC_SPI_MASTER msgresponse */
+#define MC_CMD_AOE_OUT_MC_SPI_MASTER_LEN 0
+
+
+/***********************************/
+/* MC_CMD_PTP
+ * Perform PTP operation
+ */
+#define MC_CMD_PTP 0xb
+
+/* MC_CMD_PTP_IN msgrequest */
+#define MC_CMD_PTP_IN_LEN 1
+#define MC_CMD_PTP_IN_OP_OFST 0
+#define MC_CMD_PTP_IN_OP_LEN 1
+#define MC_CMD_PTP_OP_ENABLE 0x1 /* enum */
+#define MC_CMD_PTP_OP_DISABLE 0x2 /* enum */
+#define MC_CMD_PTP_OP_TRANSMIT 0x3 /* enum */
+#define MC_CMD_PTP_OP_READ_NIC_TIME 0x4 /* enum */
+#define MC_CMD_PTP_OP_STATUS 0x5 /* enum */
+#define MC_CMD_PTP_OP_ADJUST 0x6 /* enum */
+#define MC_CMD_PTP_OP_SYNCHRONIZE 0x7 /* enum */
+#define MC_CMD_PTP_OP_MANFTEST_BASIC 0x8 /* enum */
+#define MC_CMD_PTP_OP_MANFTEST_PACKET 0x9 /* enum */
+#define MC_CMD_PTP_OP_RESET_STATS 0xa /* enum */
+#define MC_CMD_PTP_OP_DEBUG 0xb /* enum */
+#define MC_CMD_PTP_OP_FPGAREAD 0xc /* enum */
+#define MC_CMD_PTP_OP_FPGAWRITE 0xd /* enum */
+#define MC_CMD_PTP_OP_CLOCK_OFFSET_ADJUST 0xe /* enum */
+#define MC_CMD_PTP_OP_CLOCK_FREQ_ADJUST 0xf /* enum */
+#define MC_CMD_PTP_OP_RX_SET_VLAN_FILTER 0x10 /* enum */
+#define MC_CMD_PTP_OP_RX_SET_UUID_FILTER 0x11 /* enum */
+#define MC_CMD_PTP_OP_RX_SET_DOMAIN_FILTER 0x12 /* enum */
+#define MC_CMD_PTP_OP_SET_CLK_SRC 0x13 /* enum */
+#define MC_CMD_PTP_OP_RST_CLK 0x14 /* enum */
+#define MC_CMD_PTP_OP_PPS_ENABLE 0x15 /* enum */
+#define MC_CMD_PTP_OP_MAX 0x16 /* enum */
+
+/* MC_CMD_PTP_IN_ENABLE msgrequest */
+#define MC_CMD_PTP_IN_ENABLE_LEN 16
+#define MC_CMD_PTP_IN_CMD_OFST 0
+#define MC_CMD_PTP_IN_PERIPH_ID_OFST 4
+#define MC_CMD_PTP_IN_ENABLE_QUEUE_OFST 8
+#define MC_CMD_PTP_IN_ENABLE_MODE_OFST 12
+#define MC_CMD_PTP_MODE_V1 0x0 /* enum */
+#define MC_CMD_PTP_MODE_V1_VLAN 0x1 /* enum */
+#define MC_CMD_PTP_MODE_V2 0x2 /* enum */
+#define MC_CMD_PTP_MODE_V2_VLAN 0x3 /* enum */
+#define MC_CMD_PTP_MODE_V2_ENHANCED 0x4 /* enum */
+
+/* MC_CMD_PTP_IN_DISABLE msgrequest */
+#define MC_CMD_PTP_IN_DISABLE_LEN 8
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+
+/* MC_CMD_PTP_IN_TRANSMIT msgrequest */
+#define MC_CMD_PTP_IN_TRANSMIT_LENMIN 13
+#define MC_CMD_PTP_IN_TRANSMIT_LENMAX 252
+#define MC_CMD_PTP_IN_TRANSMIT_LEN(num) (12+1*(num))
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_TRANSMIT_LENGTH_OFST 8
+#define MC_CMD_PTP_IN_TRANSMIT_PACKET_OFST 12
+#define MC_CMD_PTP_IN_TRANSMIT_PACKET_LEN 1
+#define MC_CMD_PTP_IN_TRANSMIT_PACKET_MINNUM 1
+#define MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM 240
+
+/* MC_CMD_PTP_IN_READ_NIC_TIME msgrequest */
+#define MC_CMD_PTP_IN_READ_NIC_TIME_LEN 8
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+
+/* MC_CMD_PTP_IN_STATUS msgrequest */
+#define MC_CMD_PTP_IN_STATUS_LEN 8
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+
+/* MC_CMD_PTP_IN_ADJUST msgrequest */
+#define MC_CMD_PTP_IN_ADJUST_LEN 24
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_ADJUST_FREQ_OFST 8
+#define MC_CMD_PTP_IN_ADJUST_FREQ_LEN 8
+#define MC_CMD_PTP_IN_ADJUST_FREQ_LO_OFST 8
+#define MC_CMD_PTP_IN_ADJUST_FREQ_HI_OFST 12
+#define MC_CMD_PTP_IN_ADJUST_BITS 0x28 /* enum */
+#define MC_CMD_PTP_IN_ADJUST_SECONDS_OFST 16
+#define MC_CMD_PTP_IN_ADJUST_NANOSECONDS_OFST 20
+
+/* MC_CMD_PTP_IN_SYNCHRONIZE msgrequest */
+#define MC_CMD_PTP_IN_SYNCHRONIZE_LEN 20
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_SYNCHRONIZE_NUMTIMESETS_OFST 8
+#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_OFST 12
+#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LEN 8
+#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LO_OFST 12
+#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_HI_OFST 16
+
+/* MC_CMD_PTP_IN_MANFTEST_BASIC msgrequest */
+#define MC_CMD_PTP_IN_MANFTEST_BASIC_LEN 8
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+
+/* MC_CMD_PTP_IN_MANFTEST_PACKET msgrequest */
+#define MC_CMD_PTP_IN_MANFTEST_PACKET_LEN 12
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_MANFTEST_PACKET_TEST_ENABLE_OFST 8
+
+/* MC_CMD_PTP_IN_RESET_STATS msgrequest */
+#define MC_CMD_PTP_IN_RESET_STATS_LEN 8
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+
+/* MC_CMD_PTP_IN_DEBUG msgrequest */
+#define MC_CMD_PTP_IN_DEBUG_LEN 12
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_DEBUG_DEBUG_PARAM_OFST 8
+
+/* MC_CMD_PTP_IN_FPGAREAD msgrequest */
+#define MC_CMD_PTP_IN_FPGAREAD_LEN 16
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_FPGAREAD_ADDR_OFST 8
+#define MC_CMD_PTP_IN_FPGAREAD_NUMBYTES_OFST 12
+
+/* MC_CMD_PTP_IN_FPGAWRITE msgrequest */
+#define MC_CMD_PTP_IN_FPGAWRITE_LENMIN 13
+#define MC_CMD_PTP_IN_FPGAWRITE_LENMAX 252
+#define MC_CMD_PTP_IN_FPGAWRITE_LEN(num) (12+1*(num))
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_FPGAWRITE_ADDR_OFST 8
+#define MC_CMD_PTP_IN_FPGAWRITE_BUFFER_OFST 12
+#define MC_CMD_PTP_IN_FPGAWRITE_BUFFER_LEN 1
+#define MC_CMD_PTP_IN_FPGAWRITE_BUFFER_MINNUM 1
+#define MC_CMD_PTP_IN_FPGAWRITE_BUFFER_MAXNUM 240
+
+/* MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST msgrequest */
+#define MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST_LEN 16
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST_SECONDS_OFST 8
+#define MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST_NANOSECONDS_OFST 12
+
+/* MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST msgrequest */
+#define MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_LEN 16
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_OFST 8
+#define MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_LEN 8
+#define MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_LO_OFST 8
+#define MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_HI_OFST 12
+/* MC_CMD_PTP_IN_ADJUST_BITS 0x28 */
+
+/* MC_CMD_PTP_IN_RX_SET_VLAN_FILTER msgrequest */
+#define MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_LEN 24
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_NUM_VLAN_TAGS_OFST 8
+#define MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_VLAN_TAG_OFST 12
+#define MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_VLAN_TAG_LEN 4
+#define MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_VLAN_TAG_NUM 3
+
+/* MC_CMD_PTP_IN_RX_SET_UUID_FILTER msgrequest */
+#define MC_CMD_PTP_IN_RX_SET_UUID_FILTER_LEN 20
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_RX_SET_UUID_FILTER_ENABLE_OFST 8
+#define MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_OFST 12
+#define MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_LEN 8
+#define MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_LO_OFST 12
+#define MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_HI_OFST 16
+
+/* MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER msgrequest */
+#define MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER_LEN 16
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER_ENABLE_OFST 8
+#define MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER_DOMAIN_OFST 12
+
+/* MC_CMD_PTP_IN_PPS_ENABLE msgrequest */
+#define MC_CMD_PTP_IN_PPS_ENABLE_LEN 12
+/* MC_CMD_PTP_IN_CMD_OFST 0 */
+#define MC_CMD_PTP_IN_PPS_ENABLE_OP_OFST 4
+#define MC_CMD_PTP_ENABLE_PPS 0x0 /* enum */
+#define MC_CMD_PTP_DISABLE_PPS 0x1 /* enum */
+#define MC_CMD_PTP_IN_PPS_ENABLE_QUEUE_ID_OFST 8
+
+/* MC_CMD_PTP_OUT msgresponse */
+#define MC_CMD_PTP_OUT_LEN 0
+
+/* MC_CMD_PTP_OUT_TRANSMIT msgresponse */
+#define MC_CMD_PTP_OUT_TRANSMIT_LEN 8
+#define MC_CMD_PTP_OUT_TRANSMIT_SECONDS_OFST 0
+#define MC_CMD_PTP_OUT_TRANSMIT_NANOSECONDS_OFST 4
+
+/* MC_CMD_PTP_OUT_READ_NIC_TIME msgresponse */
+#define MC_CMD_PTP_OUT_READ_NIC_TIME_LEN 8
+#define MC_CMD_PTP_OUT_READ_NIC_TIME_SECONDS_OFST 0
+#define MC_CMD_PTP_OUT_READ_NIC_TIME_NANOSECONDS_OFST 4
+
+/* MC_CMD_PTP_OUT_STATUS msgresponse */
+#define MC_CMD_PTP_OUT_STATUS_LEN 64
+#define MC_CMD_PTP_OUT_STATUS_CLOCK_FREQ_OFST 0
+#define MC_CMD_PTP_OUT_STATUS_STATS_TX_OFST 4
+#define MC_CMD_PTP_OUT_STATUS_STATS_RX_OFST 8
+#define MC_CMD_PTP_OUT_STATUS_STATS_TS_OFST 12
+#define MC_CMD_PTP_OUT_STATUS_STATS_FM_OFST 16
+#define MC_CMD_PTP_OUT_STATUS_STATS_NFM_OFST 20
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFLOW_OFST 24
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_BAD_OFST 28
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MIN_OFST 32
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MAX_OFST 36
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_LAST_OFST 40
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MEAN_OFST 44
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MIN_OFST 48
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MAX_OFST 52
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_LAST_OFST 56
+#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MEAN_OFST 60
+
+/* MC_CMD_PTP_OUT_SYNCHRONIZE msgresponse */
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_LENMIN 20
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_LENMAX 240
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_LEN(num) (0+20*(num))
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_OFST 0
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN 20
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MINNUM 1
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM 12
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTSTART_OFST 0
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_SECONDS_OFST 4
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_NANOSECONDS_OFST 8
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTEND_OFST 12
+#define MC_CMD_PTP_OUT_SYNCHRONIZE_WAITNS_OFST 16
+
+/* MC_CMD_PTP_OUT_MANFTEST_BASIC msgresponse */
+#define MC_CMD_PTP_OUT_MANFTEST_BASIC_LEN 8
+#define MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_RESULT_OFST 0
+#define MC_CMD_PTP_MANF_SUCCESS 0x0 /* enum */
+#define MC_CMD_PTP_MANF_FPGA_LOAD 0x1 /* enum */
+#define MC_CMD_PTP_MANF_FPGA_VERSION 0x2 /* enum */
+#define MC_CMD_PTP_MANF_FPGA_REGISTERS 0x3 /* enum */
+#define MC_CMD_PTP_MANF_OSCILLATOR 0x4 /* enum */
+#define MC_CMD_PTP_MANF_TIMESTAMPS 0x5 /* enum */
+#define MC_CMD_PTP_MANF_PACKET_COUNT 0x6 /* enum */
+#define MC_CMD_PTP_MANF_FILTER_COUNT 0x7 /* enum */
+#define MC_CMD_PTP_MANF_PACKET_ENOUGH 0x8 /* enum */
+#define MC_CMD_PTP_MANF_GPIO_TRIGGER 0x9 /* enum */
+#define MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_EXTOSC_OFST 4
+
+/* MC_CMD_PTP_OUT_MANFTEST_PACKET msgresponse */
+#define MC_CMD_PTP_OUT_MANFTEST_PACKET_LEN 12
+#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_RESULT_OFST 0
+#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FPGACOUNT_OFST 4
+#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FILTERCOUNT_OFST 8
+
+/* MC_CMD_PTP_OUT_FPGAREAD msgresponse */
+#define MC_CMD_PTP_OUT_FPGAREAD_LENMIN 1
+#define MC_CMD_PTP_OUT_FPGAREAD_LENMAX 252
+#define MC_CMD_PTP_OUT_FPGAREAD_LEN(num) (0+1*(num))
+#define MC_CMD_PTP_OUT_FPGAREAD_BUFFER_OFST 0
+#define MC_CMD_PTP_OUT_FPGAREAD_BUFFER_LEN 1
+#define MC_CMD_PTP_OUT_FPGAREAD_BUFFER_MINNUM 1
+#define MC_CMD_PTP_OUT_FPGAREAD_BUFFER_MAXNUM 252
+
+
+/***********************************/
/* MC_CMD_CSR_READ32
* Read 32bit words from the indirect memory map.
*/
@@ -538,6 +2717,31 @@
/***********************************/
+/* MC_CMD_HP
+ * HP specific commands.
+ */
+#define MC_CMD_HP 0x54
+
+/* MC_CMD_HP_IN msgrequest */
+#define MC_CMD_HP_IN_LEN 16
+#define MC_CMD_HP_IN_SUBCMD_OFST 0
+#define MC_CMD_HP_IN_OCSD_SUBCMD 0x0 /* enum */
+#define MC_CMD_HP_IN_LAST_SUBCMD 0x0 /* enum */
+#define MC_CMD_HP_IN_OCSD_ADDR_OFST 4
+#define MC_CMD_HP_IN_OCSD_ADDR_LEN 8
+#define MC_CMD_HP_IN_OCSD_ADDR_LO_OFST 4
+#define MC_CMD_HP_IN_OCSD_ADDR_HI_OFST 8
+#define MC_CMD_HP_IN_OCSD_INTERVAL_OFST 12
+
+/* MC_CMD_HP_OUT msgresponse */
+#define MC_CMD_HP_OUT_LEN 4
+#define MC_CMD_HP_OUT_OCSD_STATUS_OFST 0
+#define MC_CMD_HP_OUT_OCSD_STOPPED 0x1 /* enum */
+#define MC_CMD_HP_OUT_OCSD_STARTED 0x2 /* enum */
+#define MC_CMD_HP_OUT_OCSD_ALREADY_STARTED 0x3 /* enum */
+
+
+/***********************************/
/* MC_CMD_STACKINFO
* Get stack information.
*/
@@ -718,6 +2922,18 @@
#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT0_OFST 36
#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_LBN 0x0 /* enum */
#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_WIDTH 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_TURBO_LBN 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_TURBO_WIDTH 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN 0x2 /* enum */
+#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_WIDTH 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_PTP_LBN 0x3 /* enum */
+#define MC_CMD_CAPABILITIES_PTP_WIDTH 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_AOE_LBN 0x4 /* enum */
+#define MC_CMD_CAPABILITIES_AOE_WIDTH 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_AOE_ACTIVE_LBN 0x5 /* enum */
+#define MC_CMD_CAPABILITIES_AOE_ACTIVE_WIDTH 0x1 /* enum */
+#define MC_CMD_CAPABILITIES_FC_ACTIVE_LBN 0x6 /* enum */
+#define MC_CMD_CAPABILITIES_FC_ACTIVE_WIDTH 0x1 /* enum */
#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT1_OFST 40
/* Enum values, see field(s): */
/* CAPABILITIES_PORT0 */
@@ -764,7 +2980,7 @@
/***********************************/
/* MC_CMD_SET_RAND_SEED
- * Set the 16byte seed for the MC psuedo-random generator.
+ * Set the 16byte seed for the MC pseudo-random generator.
*/
#define MC_CMD_SET_RAND_SEED 0x1a
@@ -813,29 +3029,6 @@
/***********************************/
-/* MC_CMD_NCSI_PROD
- * Trigger an NC-SI event.
- */
-#define MC_CMD_NCSI_PROD 0x1d
-
-/* MC_CMD_NCSI_PROD_IN msgrequest */
-#define MC_CMD_NCSI_PROD_IN_LEN 4
-#define MC_CMD_NCSI_PROD_IN_EVENTS_OFST 0
-#define MC_CMD_NCSI_PROD_LINKCHANGE 0x0 /* enum */
-#define MC_CMD_NCSI_PROD_RESET 0x1 /* enum */
-#define MC_CMD_NCSI_PROD_DRVATTACH 0x2 /* enum */
-#define MC_CMD_NCSI_PROD_IN_LINKCHANGE_LBN 0
-#define MC_CMD_NCSI_PROD_IN_LINKCHANGE_WIDTH 1
-#define MC_CMD_NCSI_PROD_IN_RESET_LBN 1
-#define MC_CMD_NCSI_PROD_IN_RESET_WIDTH 1
-#define MC_CMD_NCSI_PROD_IN_DRVATTACH_LBN 2
-#define MC_CMD_NCSI_PROD_IN_DRVATTACH_WIDTH 1
-
-/* MC_CMD_NCSI_PROD_OUT msgresponse */
-#define MC_CMD_NCSI_PROD_OUT_LEN 0
-
-
-/***********************************/
/* MC_CMD_SHMUART
* Route UART output to circular buffer in shared memory instead.
*/
@@ -937,7 +3130,7 @@
/* MC_CMD_PUTS_IN msgrequest */
#define MC_CMD_PUTS_IN_LENMIN 13
-#define MC_CMD_PUTS_IN_LENMAX 255
+#define MC_CMD_PUTS_IN_LENMAX 252
#define MC_CMD_PUTS_IN_LEN(num) (12+1*(num))
#define MC_CMD_PUTS_IN_DEST_OFST 0
#define MC_CMD_PUTS_IN_UART_LBN 0
@@ -949,7 +3142,7 @@
#define MC_CMD_PUTS_IN_STRING_OFST 12
#define MC_CMD_PUTS_IN_STRING_LEN 1
#define MC_CMD_PUTS_IN_STRING_MINNUM 1
-#define MC_CMD_PUTS_IN_STRING_MAXNUM 243
+#define MC_CMD_PUTS_IN_STRING_MAXNUM 240
/* MC_CMD_PUTS_OUT msgresponse */
#define MC_CMD_PUTS_OUT_LEN 0
@@ -1003,6 +3196,8 @@
#define MC_CMD_PHY_CAP_ASYM_WIDTH 1
#define MC_CMD_PHY_CAP_AN_LBN 10
#define MC_CMD_PHY_CAP_AN_WIDTH 1
+#define MC_CMD_PHY_CAP_DDM_LBN 12
+#define MC_CMD_PHY_CAP_DDM_WIDTH 1
#define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12
#define MC_CMD_GET_PHY_CFG_OUT_PRT_OFST 16
#define MC_CMD_GET_PHY_CFG_OUT_STATS_MASK_OFST 20
@@ -1171,6 +3366,7 @@
#define MC_CMD_LOOPBACK_XFI_WS 0x18 /* enum */
#define MC_CMD_LOOPBACK_XFI_WS_FAR 0x19 /* enum */
#define MC_CMD_LOOPBACK_PHYXS_WS 0x1a /* enum */
+#define MC_CMD_LOOPBACK_AOE_INT_NEAR 0x23 /* enum */
#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_OFST 8
#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LEN 8
#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LO_OFST 8
@@ -1217,6 +3413,10 @@
#define MC_CMD_GET_LINK_OUT_BPX_LINK_WIDTH 1
#define MC_CMD_GET_LINK_OUT_PHY_LINK_LBN 3
#define MC_CMD_GET_LINK_OUT_PHY_LINK_WIDTH 1
+#define MC_CMD_GET_LINK_OUT_LINK_FAULT_RX_LBN 6
+#define MC_CMD_GET_LINK_OUT_LINK_FAULT_RX_WIDTH 1
+#define MC_CMD_GET_LINK_OUT_LINK_FAULT_TX_LBN 7
+#define MC_CMD_GET_LINK_OUT_LINK_FAULT_TX_WIDTH 1
#define MC_CMD_GET_LINK_OUT_FCNTL_OFST 20
#define MC_CMD_FCNTL_OFF 0x0 /* enum */
#define MC_CMD_FCNTL_RESPOND 0x1 /* enum */
@@ -1678,6 +3878,14 @@
#define MC_CMD_NVRAM_TYPE_PHY_PORT0 0xa /* enum */
#define MC_CMD_NVRAM_TYPE_PHY_PORT1 0xb /* enum */
#define MC_CMD_NVRAM_TYPE_LOG 0xc /* enum */
+#define MC_CMD_NVRAM_TYPE_FPGA 0xd /* enum */
+#define MC_CMD_NVRAM_TYPE_FPGA_BACKUP 0xe /* enum */
+#define MC_CMD_NVRAM_TYPE_FC_FW 0xf /* enum */
+#define MC_CMD_NVRAM_TYPE_FC_FW_BACKUP 0x10 /* enum */
+#define MC_CMD_NVRAM_TYPE_CPLD 0x11 /* enum */
+#define MC_CMD_NVRAM_TYPE_LICENSE 0x12 /* enum */
+#define MC_CMD_NVRAM_TYPE_FC_LOG 0x13 /* enum */
+#define MC_CMD_NVRAM_TYPE_FC_EXTRA 0x14 /* enum */
/***********************************/
@@ -1738,12 +3946,12 @@
/* MC_CMD_NVRAM_READ_OUT msgresponse */
#define MC_CMD_NVRAM_READ_OUT_LENMIN 1
-#define MC_CMD_NVRAM_READ_OUT_LENMAX 255
+#define MC_CMD_NVRAM_READ_OUT_LENMAX 252
#define MC_CMD_NVRAM_READ_OUT_LEN(num) (0+1*(num))
#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_OFST 0
#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_LEN 1
#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MINNUM 1
-#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MAXNUM 255
+#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MAXNUM 252
/***********************************/
@@ -1754,7 +3962,7 @@
/* MC_CMD_NVRAM_WRITE_IN msgrequest */
#define MC_CMD_NVRAM_WRITE_IN_LENMIN 13
-#define MC_CMD_NVRAM_WRITE_IN_LENMAX 255
+#define MC_CMD_NVRAM_WRITE_IN_LENMAX 252
#define MC_CMD_NVRAM_WRITE_IN_LEN(num) (12+1*(num))
#define MC_CMD_NVRAM_WRITE_IN_TYPE_OFST 0
/* Enum values, see field(s): */
@@ -1764,7 +3972,7 @@
#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_OFST 12
#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_LEN 1
#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MINNUM 1
-#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MAXNUM 243
+#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MAXNUM 240
/* MC_CMD_NVRAM_WRITE_OUT msgresponse */
#define MC_CMD_NVRAM_WRITE_OUT_LEN 0
@@ -1882,6 +4090,21 @@
#define MC_CMD_SENSOR_IN_2V5 0xa /* enum */
#define MC_CMD_SENSOR_IN_3V3 0xb /* enum */
#define MC_CMD_SENSOR_IN_12V0 0xc /* enum */
+#define MC_CMD_SENSOR_IN_1V2A 0xd /* enum */
+#define MC_CMD_SENSOR_IN_VREF 0xe /* enum */
+#define MC_CMD_SENSOR_OUT_VAOE 0xf /* enum */
+#define MC_CMD_SENSOR_AOE_TEMP 0x10 /* enum */
+#define MC_CMD_SENSOR_PSU_AOE_TEMP 0x11 /* enum */
+#define MC_CMD_SENSOR_PSU_TEMP 0x12 /* enum */
+#define MC_CMD_SENSOR_FAN_0 0x13 /* enum */
+#define MC_CMD_SENSOR_FAN_1 0x14 /* enum */
+#define MC_CMD_SENSOR_FAN_2 0x15 /* enum */
+#define MC_CMD_SENSOR_FAN_3 0x16 /* enum */
+#define MC_CMD_SENSOR_FAN_4 0x17 /* enum */
+#define MC_CMD_SENSOR_IN_VAOE 0x18 /* enum */
+#define MC_CMD_SENSOR_OUT_IAOE 0x19 /* enum */
+#define MC_CMD_SENSOR_IN_IAOE 0x1a /* enum */
+#define MC_CMD_SENSOR_NIC_POWER 0x1b /* enum */
#define MC_CMD_SENSOR_ENTRY_OFST 4
#define MC_CMD_SENSOR_ENTRY_LEN 8
#define MC_CMD_SENSOR_ENTRY_LO_OFST 4
@@ -2094,13 +4317,13 @@
/* MC_CMD_GET_PHY_MEDIA_INFO_OUT msgresponse */
#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMIN 5
-#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX 255
+#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX 252
#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(num) (4+1*(num))
#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0
#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4
#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_LEN 1
#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MINNUM 1
-#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MAXNUM 251
+#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MAXNUM 248
/***********************************/
@@ -2183,6 +4406,74 @@
#define MC_CMD_GET_RESOURCE_LIMITS_OUT_RXQ_OFST 8
#define MC_CMD_GET_RESOURCE_LIMITS_OUT_TXQ_OFST 12
+
+/***********************************/
+/* MC_CMD_CLP
+ * CLP support operations
+ */
+#define MC_CMD_CLP 0x56
+
+/* MC_CMD_CLP_IN msgrequest */
+#define MC_CMD_CLP_IN_LEN 4
+#define MC_CMD_CLP_IN_OP_OFST 0
+#define MC_CMD_CLP_OP_DEFAULT 0x1 /* enum */
+#define MC_CMD_CLP_OP_SET_MAC 0x2 /* enum */
+#define MC_CMD_CLP_OP_GET_MAC 0x3 /* enum */
+#define MC_CMD_CLP_OP_SET_BOOT 0x4 /* enum */
+#define MC_CMD_CLP_OP_GET_BOOT 0x5 /* enum */
+
+/* MC_CMD_CLP_OUT msgresponse */
+#define MC_CMD_CLP_OUT_LEN 0
+
+/* MC_CMD_CLP_IN_DEFAULT msgrequest */
+#define MC_CMD_CLP_IN_DEFAULT_LEN 4
+/* MC_CMD_CLP_IN_OP_OFST 0 */
+
+/* MC_CMD_CLP_OUT_DEFAULT msgresponse */
+#define MC_CMD_CLP_OUT_DEFAULT_LEN 0
+
+/* MC_CMD_CLP_IN_SET_MAC msgrequest */
+#define MC_CMD_CLP_IN_SET_MAC_LEN 12
+/* MC_CMD_CLP_IN_OP_OFST 0 */
+#define MC_CMD_CLP_IN_SET_MAC_ADDR_OFST 4
+#define MC_CMD_CLP_IN_SET_MAC_ADDR_LEN 6
+#define MC_CMD_CLP_IN_SET_MAC_RESERVED_OFST 10
+#define MC_CMD_CLP_IN_SET_MAC_RESERVED_LEN 2
+
+/* MC_CMD_CLP_OUT_SET_MAC msgresponse */
+#define MC_CMD_CLP_OUT_SET_MAC_LEN 0
+
+/* MC_CMD_CLP_IN_GET_MAC msgrequest */
+#define MC_CMD_CLP_IN_GET_MAC_LEN 4
+/* MC_CMD_CLP_IN_OP_OFST 0 */
+
+/* MC_CMD_CLP_OUT_GET_MAC msgresponse */
+#define MC_CMD_CLP_OUT_GET_MAC_LEN 8
+#define MC_CMD_CLP_OUT_GET_MAC_ADDR_OFST 0
+#define MC_CMD_CLP_OUT_GET_MAC_ADDR_LEN 6
+#define MC_CMD_CLP_OUT_GET_MAC_RESERVED_OFST 6
+#define MC_CMD_CLP_OUT_GET_MAC_RESERVED_LEN 2
+
+/* MC_CMD_CLP_IN_SET_BOOT msgrequest */
+#define MC_CMD_CLP_IN_SET_BOOT_LEN 5
+/* MC_CMD_CLP_IN_OP_OFST 0 */
+#define MC_CMD_CLP_IN_SET_BOOT_FLAG_OFST 4
+#define MC_CMD_CLP_IN_SET_BOOT_FLAG_LEN 1
+
+/* MC_CMD_CLP_OUT_SET_BOOT msgresponse */
+#define MC_CMD_CLP_OUT_SET_BOOT_LEN 0
+
+/* MC_CMD_CLP_IN_GET_BOOT msgrequest */
+#define MC_CMD_CLP_IN_GET_BOOT_LEN 4
+/* MC_CMD_CLP_IN_OP_OFST 0 */
+
+/* MC_CMD_CLP_OUT_GET_BOOT msgresponse */
+#define MC_CMD_CLP_OUT_GET_BOOT_LEN 4
+#define MC_CMD_CLP_OUT_GET_BOOT_FLAG_OFST 0
+#define MC_CMD_CLP_OUT_GET_BOOT_FLAG_LEN 1
+#define MC_CMD_CLP_OUT_GET_BOOT_RESERVED_OFST 1
+#define MC_CMD_CLP_OUT_GET_BOOT_RESERVED_LEN 3
+
/* MC_CMD_RESOURCE_SPECIFIER enum */
#define MC_CMD_RESOURCE_INSTANCE_ANY 0xffffffff /* enum */
#define MC_CMD_RESOURCE_INSTANCE_NONE 0xfffffffe /* enum */
@@ -2292,6 +4583,8 @@
#define MC_CMD_INIT_TXQ_IN_FLAG_IP_CSUM_DIS_WIDTH 1
#define MC_CMD_INIT_TXQ_IN_FLAG_TCP_CSUM_DIS_LBN 2
#define MC_CMD_INIT_TXQ_IN_FLAG_TCP_CSUM_DIS_WIDTH 1
+#define MC_CMD_INIT_TXQ_IN_FLAG_TCP_UDP_ONLY_LBN 3
+#define MC_CMD_INIT_TXQ_IN_FLAG_TCP_UDP_ONLY_WIDTH 1
#define MC_CMD_INIT_TXQ_IN_CRC_MODE_LBN 4
#define MC_CMD_INIT_TXQ_IN_CRC_MODE_WIDTH 4
#define MC_CMD_INIT_TXQ_IN_OWNER_ID_OFST 20
@@ -2768,9 +5061,23 @@
/***********************************/
+/* MC_CMD_TCM_BUCKET_INIT
+ */
+#define MC_CMD_TCM_BUCKET_INIT 0x82
+
+/* MC_CMD_TCM_BUCKET_INIT_IN msgrequest */
+#define MC_CMD_TCM_BUCKET_INIT_IN_LEN 8
+#define MC_CMD_TCM_BUCKET_INIT_IN_BUCKET_OFST 0
+#define MC_CMD_TCM_BUCKET_INIT_IN_RATE_OFST 4
+
+/* MC_CMD_TCM_BUCKET_INIT_OUT msgresponse */
+#define MC_CMD_TCM_BUCKET_INIT_OUT_LEN 0
+
+
+/***********************************/
/* MC_CMD_TCM_TXQ_INIT
*/
-#define MC_CMD_TCM_TXQ_INIT 0x82
+#define MC_CMD_TCM_TXQ_INIT 0x83
/* MC_CMD_TCM_TXQ_INIT_IN msgrequest */
#define MC_CMD_TCM_TXQ_INIT_IN_LEN 28
diff --git a/sys/dev/sfxge/common/efx_tx.c b/sys/dev/sfxge/common/efx_tx.c
index dcc225d..2ee9c10 100644
--- a/sys/dev/sfxge/common/efx_tx.c
+++ b/sys/dev/sfxge/common/efx_tx.c
@@ -289,8 +289,9 @@ efx_tx_qcreate(
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_TX);
- EFX_STATIC_ASSERT(EFX_EV_TX_NLABELS == (1 << FRF_AZ_TX_DESCQ_LABEL_WIDTH));
- /* EFSYS_ASSERT3U(label, <, EFX_EV_TX_NLABELS);*/
+ EFX_STATIC_ASSERT(EFX_EV_TX_NLABELS ==
+ (1 << FRF_AZ_TX_DESCQ_LABEL_WIDTH));
+ EFSYS_ASSERT3U(label, <, EFX_EV_TX_NLABELS);
EFSYS_ASSERT3U(enp->en_tx_qcount + 1, <, encp->enc_txq_limit);
if (!ISP2(n) || !(n & EFX_TXQ_NDESCS_MASK)) {
diff --git a/sys/dev/sfxge/common/siena_mac.c b/sys/dev/sfxge/common/siena_mac.c
index e5c8f3c..38f5bc5 100644
--- a/sys/dev/sfxge/common/siena_mac.c
+++ b/sys/dev/sfxge/common/siena_mac.c
@@ -534,6 +534,7 @@ siena_mac_stats_update(
&generation_start);
/* Check that we didn't read the stats in the middle of a DMA */
+ /* Not a good enough check ? */
if (memcmp(&generation_start, &generation_end,
sizeof (generation_start)))
return (EAGAIN);
diff --git a/sys/dev/sfxge/common/siena_mon.c b/sys/dev/sfxge/common/siena_mon.c
index dc3e59e..ed337bd 100644
--- a/sys/dev/sfxge/common/siena_mon.c
+++ b/sys/dev/sfxge/common/siena_mon.c
@@ -105,6 +105,7 @@ siena_mon_decode_stats(
uint16_t mc_sensor;
size_t mc_sensor_max;
uint32_t vmask = 0;
+ uint32_t idx = 0;
/* Assert the MC_CMD_SENSOR and EFX_MON_STATE namespaces agree */
SIENA_STATIC_SENSOR_ASSERT(OK);
@@ -125,18 +126,19 @@ siena_mon_decode_stats(
for (mc_sensor = 0; mc_sensor < mc_sensor_max; ++mc_sensor) {
uint16_t efx_sensor = sensor_map[mc_sensor];
- if (efx_sensor == SIENA_MON_WRONG_PORT)
+ if (~dmask & (1 << mc_sensor))
continue;
- EFSYS_ASSERT(efx_sensor < EFX_MON_NSTATS);
+ idx++;
- if (~dmask & (1 << mc_sensor))
+ if (efx_sensor == SIENA_MON_WRONG_PORT)
continue;
+ EFSYS_ASSERT(efx_sensor < EFX_MON_NSTATS);
vmask |= (1 << efx_sensor);
if (value != NULL && esmp != NULL && !EFSYS_MEM_IS_NULL(esmp)) {
efx_mon_stat_value_t *emsvp = value + efx_sensor;
efx_dword_t dword;
- EFSYS_MEM_READD(esmp, 4 * mc_sensor, &dword);
+ EFSYS_MEM_READD(esmp, 4 * (idx - 1), &dword);
emsvp->emsv_value =
(uint16_t)EFX_DWORD_FIELD(
dword,
diff --git a/sys/dev/sfxge/common/siena_nic.c b/sys/dev/sfxge/common/siena_nic.c
index eba0a18..1e97adb 100644
--- a/sys/dev/sfxge/common/siena_nic.c
+++ b/sys/dev/sfxge/common/siena_nic.c
@@ -279,7 +279,8 @@ siena_board_cfg(
uint8_t outbuf[MAX(MC_CMD_GET_BOARD_CFG_OUT_LENMIN,
MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN)];
efx_mcdi_req_t req;
- uint8_t *src;
+ uint8_t *mac_addr;
+ efx_dword_t *capabilities;
int rc;
/* Board configuration */
@@ -302,17 +303,35 @@ siena_board_cfg(
goto fail2;
}
- if (emip->emi_port == 1)
- src = MCDI_OUT2(req, uint8_t,
+ if (emip->emi_port == 1) {
+ mac_addr = MCDI_OUT2(req, uint8_t,
GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0);
- else
- src = MCDI_OUT2(req, uint8_t,
+ capabilities = MCDI_OUT2(req, efx_dword_t,
+ GET_BOARD_CFG_OUT_CAPABILITIES_PORT0);
+ } else {
+ mac_addr = MCDI_OUT2(req, uint8_t,
GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1);
- EFX_MAC_ADDR_COPY(encp->enc_mac_addr, src);
+ capabilities = MCDI_OUT2(req, efx_dword_t,
+ GET_BOARD_CFG_OUT_CAPABILITIES_PORT1);
+ }
+ EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
encp->enc_board_type = MCDI_OUT_DWORD(req,
GET_BOARD_CFG_OUT_BOARD_TYPE);
+ /* Additional capabilities */
+ encp->enc_clk_mult = 1;
+ if (MCDI_CMD_DWORD_FIELD(capabilities, CAPABILITIES_TURBO)) {
+ enp->en_features |= EFX_FEATURE_TURBO;
+
+ if (MCDI_CMD_DWORD_FIELD(capabilities,
+ CAPABILITIES_TURBO_ACTIVE))
+ encp->enc_clk_mult = 2;
+ }
+
+ encp->enc_evq_moderation_max = EFX_EV_TIMER_QUANTUM <<
+ FRF_AB_TIMER_VAL_WIDTH / encp->enc_clk_mult;
+
/* Resource limits */
req.emr_cmd = MC_CMD_GET_RESOURCE_LIMITS;
EFX_STATIC_ASSERT(MC_CMD_GET_RESOURCE_LIMITS_IN_LEN == 0);
@@ -346,7 +365,8 @@ siena_board_cfg(
}
encp->enc_buftbl_limit = SIENA_SRAM_ROWS -
- (encp->enc_txq_limit * 16) - (encp->enc_rxq_limit * 64);
+ (encp->enc_txq_limit * EFX_TXQ_DC_NDESCS(EFX_TXQ_DC_SIZE)) -
+ (encp->enc_rxq_limit * EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
return (0);
@@ -458,7 +478,7 @@ siena_phy_cfg(
if (MCDI_OUT_DWORD_FIELD(req, GET_PHY_CFG_OUT_FLAGS,
GET_PHY_CFG_OUT_BIST))
encp->enc_bist_mask |= (1 << EFX_PHY_BIST_TYPE_NORMAL);
-#endif /* EFSYS_OPT_BIST */
+#endif /* EFSYS_OPT_PHY_BIST */
return (0);
@@ -590,7 +610,6 @@ siena_nic_probe(
unsigned int mask;
int rc;
- mask = 0; /* XXX: pacify gcc */
EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA);
/* Read clear any assertion state */
@@ -608,9 +627,6 @@ siena_nic_probe(
if ((rc = siena_board_cfg(enp)) != 0)
goto fail4;
- encp->enc_evq_moderation_max =
- EFX_EV_TIMER_QUANTUM << FRF_CZ_TIMER_VAL_WIDTH;
-
if ((rc = siena_phy_cfg(enp)) != 0)
goto fail5;
@@ -888,7 +904,7 @@ static efx_register_set_t __cs __siena_tables[] = {
static const uint32_t __cs __siena_table_masks[] = {
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000003FF,
0xFFFF0FFF, 0xFFFFFFFF, 0x00000E7F, 0x00000000,
- 0xFFFFFFFF, 0x0FFFFFFF, 0x01800000, 0x00000000,
+ 0xFFFFFFFE, 0x0FFFFFFF, 0x01800000, 0x00000000,
0xFFFFFFFE, 0x0FFFFFFF, 0x0C000000, 0x00000000,
0x3FFFFFFF, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x000013FF,
diff --git a/sys/dev/sfxge/common/siena_nvram.c b/sys/dev/sfxge/common/siena_nvram.c
index 249293d..daf8aab 100644
--- a/sys/dev/sfxge/common/siena_nvram.c
+++ b/sys/dev/sfxge/common/siena_nvram.c
@@ -612,7 +612,7 @@ siena_nvram_get_subtype(
if (req.emr_out_length_used <
MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST +
- (partn + 1) * sizeof(efx_word_t)) {
+ (partn + 1) * sizeof (efx_word_t)) {
rc = ENOENT;
goto fail3;
}
diff --git a/sys/dev/sfxge/common/siena_sram.c b/sys/dev/sfxge/common/siena_sram.c
index 9c13e1d..3137e5b 100644
--- a/sys/dev/sfxge/common/siena_sram.c
+++ b/sys/dev/sfxge/common/siena_sram.c
@@ -44,20 +44,21 @@ siena_sram_init(
EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA);
rx_base = encp->enc_buftbl_limit;
- tx_base = rx_base + (encp->enc_rxq_limit * 64);
+ tx_base = rx_base + (encp->enc_rxq_limit *
+ EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
/* Initialize the transmit descriptor cache */
EFX_POPULATE_OWORD_1(oword, FRF_AZ_SRM_TX_DC_BASE_ADR, tx_base);
EFX_BAR_WRITEO(enp, FR_AZ_SRM_TX_DC_CFG_REG, &oword);
- EFX_POPULATE_OWORD_1(oword, FRF_AZ_TX_DC_SIZE, 1); /* 16 descriptors */
+ EFX_POPULATE_OWORD_1(oword, FRF_AZ_TX_DC_SIZE, EFX_TXQ_DC_SIZE);
EFX_BAR_WRITEO(enp, FR_AZ_TX_DC_CFG_REG, &oword);
/* Initialize the receive descriptor cache */
EFX_POPULATE_OWORD_1(oword, FRF_AZ_SRM_RX_DC_BASE_ADR, rx_base);
EFX_BAR_WRITEO(enp, FR_AZ_SRM_RX_DC_CFG_REG, &oword);
- EFX_POPULATE_OWORD_1(oword, FRF_AZ_RX_DC_SIZE, 3); /* 64 descriptors */
+ EFX_POPULATE_OWORD_1(oword, FRF_AZ_RX_DC_SIZE, EFX_RXQ_DC_SIZE);
EFX_BAR_WRITEO(enp, FR_AZ_RX_DC_CFG_REG, &oword);
/* Set receive descriptor pre-fetch low water mark */
diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c
index 44d8491..e4c74be 100644
--- a/sys/dev/sfxge/sfxge_rx.c
+++ b/sys/dev/sfxge/sfxge_rx.c
@@ -1172,9 +1172,7 @@ sfxge_rx_stat_init(struct sfxge_softc *sc)
stat_list = SYSCTL_CHILDREN(sc->stats_node);
- for (id = 0;
- id < sizeof(sfxge_rx_stats) / sizeof(sfxge_rx_stats[0]);
- id++) {
+ for (id = 0; id < nitems(sfxge_rx_stats); id++) {
SYSCTL_ADD_PROC(
ctx, stat_list,
OID_AUTO, sfxge_rx_stats[id].name,
diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c
index 988e119..6d51468 100644
--- a/sys/dev/sfxge/sfxge_tx.c
+++ b/sys/dev/sfxge/sfxge_tx.c
@@ -67,16 +67,22 @@ __FBSDID("$FreeBSD$");
#include "sfxge.h"
#include "sfxge_tx.h"
-/* Set the block level to ensure there is space to generate a
- * large number of descriptors for TSO. With minimum MSS and
- * maximum mbuf length we might need more than a ring-ful of
- * descriptors, but this should not happen in practice except
- * due to deliberate attack. In that case we will truncate
- * the output at a packet boundary. Allow for a reasonable
- * minimum MSS of 512.
+/*
+ * Estimate maximum number of Tx descriptors required for TSO packet.
+ * With minimum MSS and maximum mbuf length we might need more (even
+ * than a ring-ful of descriptors), but this should not happen in
+ * practice except due to deliberate attack. In that case we will
+ * truncate the output at a packet boundary.
*/
-#define SFXGE_TSO_MAX_DESC ((65535 / 512) * 2 + SFXGE_TX_MAPPING_MAX_SEG - 1)
-#define SFXGE_TXQ_BLOCK_LEVEL(_entries) ((_entries) - SFXGE_TSO_MAX_DESC)
+#define SFXGE_TSO_MAX_DESC \
+ (SFXGE_TSO_MAX_SEGS * 2 + SFXGE_TX_MAPPING_MAX_SEG - 1)
+
+/*
+ * Set the block level to ensure there is space to generate a
+ * large number of descriptors for TSO.
+ */
+#define SFXGE_TXQ_BLOCK_LEVEL(_entries) \
+ (EFX_TXQ_LIMIT(_entries) - SFXGE_TSO_MAX_DESC)
#ifdef SFXGE_HAVE_MQ
@@ -505,7 +511,7 @@ sfxge_tx_qdpl_service(struct sfxge_txq *txq)
* list", otherwise we atomically push it on the "put list". The swizzle
* function takes care of ordering.
*
- * The length of the put list is bounded by SFXGE_TX_MAX_DEFFERED. We
+ * The length of the put list is bounded by SFXGE_TX_MAX_DEFERRED. We
* overload the csum_data field in the mbuf to keep track of this length
* because there is no cheap alternative to avoid races.
*/
@@ -569,7 +575,7 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked)
/*
* Called from if_transmit - will try to grab the txq lock and enqueue to the
- * put list if it succeeds, otherwise will push onto the defer list.
+ * put list if it succeeds, otherwise try to push onto the defer list if space.
*/
int
sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
@@ -865,6 +871,8 @@ static void tso_fini(struct sfxge_txq *txq)
static void tso_start(struct sfxge_tso_state *tso, struct mbuf *mbuf)
{
struct ether_header *eh = mtod(mbuf, struct ether_header *);
+ const struct tcphdr *th;
+ struct tcphdr th_copy;
tso->mbuf = mbuf;
@@ -892,13 +900,24 @@ static void tso_start(struct sfxge_tso_state *tso, struct mbuf *mbuf)
tso->tcph_off = tso->nh_off + sizeof(struct ip6_hdr);
}
- tso->header_len = tso->tcph_off + 4 * tso_tcph(tso)->th_off;
+ KASSERT(mbuf->m_len >= tso->tcph_off,
+ ("network header is fragmented in mbuf"));
+ /* We need TCP header including flags (window is the next) */
+ if (mbuf->m_len < tso->tcph_off + offsetof(struct tcphdr, th_win)) {
+ m_copydata(tso->mbuf, tso->tcph_off, sizeof(th_copy),
+ (caddr_t)&th_copy);
+ th = &th_copy;
+ } else {
+ th = tso_tcph(tso);
+ }
+
+ tso->header_len = tso->tcph_off + 4 * th->th_off;
tso->seg_size = mbuf->m_pkthdr.tso_segsz;
- tso->seqnum = ntohl(tso_tcph(tso)->th_seq);
+ tso->seqnum = ntohl(th->th_seq);
/* These flags must not be duplicated */
- KASSERT(!(tso_tcph(tso)->th_flags & (TH_URG | TH_SYN | TH_RST)),
+ KASSERT(!(th->th_flags & (TH_URG | TH_SYN | TH_RST)),
("incompatible TCP flag on TSO packet"));
tso->out_len = mbuf->m_pkthdr.len - tso->header_len;
@@ -1091,8 +1110,8 @@ sfxge_tx_queue_tso(struct sfxge_txq *txq, struct mbuf *mbuf,
* the remainder of the input mbuf but do not
* roll back the work we have done.
*/
- if (txq->n_pend_desc >
- SFXGE_TSO_MAX_DESC - (1 + SFXGE_TX_MAPPING_MAX_SEG)) {
+ if (txq->n_pend_desc + 1 /* header */ + n_dma_seg >
+ SFXGE_TSO_MAX_DESC) {
txq->tso_pdrop_too_many++;
break;
}
@@ -1130,8 +1149,11 @@ sfxge_tx_qunblock(struct sfxge_txq *txq)
unsigned int level;
level = txq->added - txq->completed;
- if (level <= SFXGE_TXQ_UNBLOCK_LEVEL(txq->entries))
+ if (level <= SFXGE_TXQ_UNBLOCK_LEVEL(txq->entries)) {
+ /* reaped must be in sync with blocked */
+ sfxge_tx_qreap(txq);
txq->blocked = 0;
+ }
}
sfxge_tx_qdpl_service(txq);
@@ -1535,9 +1557,7 @@ sfxge_tx_stat_init(struct sfxge_softc *sc)
stat_list = SYSCTL_CHILDREN(sc->stats_node);
- for (id = 0;
- id < sizeof(sfxge_tx_stats) / sizeof(sfxge_tx_stats[0]);
- id++) {
+ for (id = 0; id < nitems(sfxge_tx_stats); id++) {
SYSCTL_ADD_PROC(
ctx, stat_list,
OID_AUTO, sfxge_tx_stats[id].name,
diff --git a/sys/dev/sfxge/sfxge_tx.h b/sys/dev/sfxge/sfxge_tx.h
index ab001c1..3965ffd 100644
--- a/sys/dev/sfxge/sfxge_tx.h
+++ b/sys/dev/sfxge/sfxge_tx.h
@@ -36,18 +36,22 @@
#include <netinet/ip.h>
#include <netinet/tcp.h>
+/* Maximum size of TSO packet */
+#define SFXGE_TSO_MAX_SIZE (65535)
+
+/*
+ * Maximum number of segments to be created for a TSO packet.
+ * Allow for a reasonable minimum MSS of 512.
+ */
+#define SFXGE_TSO_MAX_SEGS howmany(SFXGE_TSO_MAX_SIZE, 512)
+
/* Maximum number of DMA segments needed to map an mbuf chain. With
* TSO, the mbuf length may be just over 64K, divided into 2K mbuf
* clusters. (The chain could be longer than this initially, but can
* be shortened with m_collapse().)
*/
-#define SFXGE_TX_MAPPING_MAX_SEG (64 / 2 + 1)
-
-/* Maximum number of DMA segments needed to map an output packet. It
- * could overlap all mbufs in the chain and also require an extra
- * segment for a TSO header.
- */
-#define SFXGE_TX_PACKET_MAX_SEG (SFXGE_TX_MAPPING_MAX_SEG + 1)
+#define SFXGE_TX_MAPPING_MAX_SEG \
+ (1 + howmany(SFXGE_TSO_MAX_SIZE, MCLBYTES))
/*
* Buffer mapping flags.
diff --git a/sys/kern/kern_ctf.c b/sys/kern/kern_ctf.c
index 15bae04..09eea1e 100644
--- a/sys/kern/kern_ctf.c
+++ b/sys/kern/kern_ctf.c
@@ -68,7 +68,6 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
int flags;
int i;
int nbytes;
- ssize_t resid;
size_t sz;
struct nameidata nd;
struct thread *td = curthread;
@@ -125,7 +124,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
/* Read the ELF header. */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, hdr, sizeof(*hdr),
- 0, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid,
+ 0, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, NULL,
td)) != 0)
goto out;
@@ -148,7 +147,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
/* Read all the section headers */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes,
hdr->e_shoff, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
- &resid, td)) != 0)
+ NULL, td)) != 0)
goto out;
/*
@@ -170,8 +169,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
/* Read the section header strings. */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, shstrtab,
shdr[hdr->e_shstrndx].sh_size, shdr[hdr->e_shstrndx].sh_offset,
- UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid,
- td)) != 0)
+ UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, NULL, td)) != 0)
goto out;
/* Search for the section containing the CTF data. */
@@ -190,7 +188,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
/* Read the CTF header. */
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, ctf_hdr, sizeof(ctf_hdr),
shdr[i].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
- NOCRED, &resid, td)) != 0)
+ NOCRED, NULL, td)) != 0)
goto out;
/* Check the CTF magic number. (XXX check for big endian!) */
@@ -249,7 +247,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
*/
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, raw == NULL ? ctftab : raw,
shdr[i].sh_size, shdr[i].sh_offset, UIO_SYSSPACE, IO_NODELOCKED,
- td->td_ucred, NOCRED, &resid, td)) != 0)
+ td->td_ucred, NOCRED, NULL, td)) != 0)
goto out;
/* Check if decompression is required. */
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index 6274bf1..3cf19e1 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -381,6 +381,8 @@ link_elf_link_common_finish(linker_file_t lf)
return (0);
}
+extern vm_offset_t __startkernel;
+
static void
link_elf_init(void* arg)
{
@@ -409,7 +411,11 @@ link_elf_init(void* arg)
ef = (elf_file_t) linker_kernel_file;
ef->preloaded = 1;
+#ifdef __powerpc64__
+ ef->address = (caddr_t) (__startkernel - KERNBASE);
+#else
ef->address = 0;
+#endif
#ifdef SPARSE_MAPPING
ef->object = 0;
#endif
@@ -417,7 +423,7 @@ link_elf_init(void* arg)
if (dp != NULL)
parse_dynamic(ef);
- linker_kernel_file->address = (caddr_t) KERNBASE;
+ linker_kernel_file->address += KERNBASE;
linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
if (modptr != NULL) {
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 98e9828..e7166f2 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -365,8 +365,6 @@ EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
#define TOEDEV(ifp) ((ifp)->if_llsoftc)
-#endif /* _KERNEL */
-
/*
* The ifaddr structure contains information about one address
* of an interface. They are maintained by the different address families,
@@ -377,7 +375,6 @@ EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
* chunk of malloc'ed memory, where we store the three addresses
* (ifa_addr, ifa_dstaddr and ifa_netmask) referenced here.
*/
-#if defined(_KERNEL) || defined(_WANT_IFADDR)
struct ifaddr {
struct sockaddr *ifa_addr; /* address of interface */
struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */
@@ -389,6 +386,8 @@ struct ifaddr {
void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
(int, struct rtentry *, struct rt_addrinfo *);
u_short ifa_flags; /* mostly rt_flags for cloning */
+#define IFA_ROUTE RTF_UP /* route installed */
+#define IFA_RTSELF RTF_HOST /* loopback route to self installed */
u_int ifa_refcnt; /* references to this structure */
counter_u64_t ifa_ipackets;
@@ -396,11 +395,6 @@ struct ifaddr {
counter_u64_t ifa_ibytes;
counter_u64_t ifa_obytes;
};
-#endif
-
-#ifdef _KERNEL
-#define IFA_ROUTE RTF_UP /* route installed */
-#define IFA_RTSELF RTF_HOST /* loopback route to self installed */
/* For compatibility with other BSDs. SCTP uses it. */
#define ifa_list ifa_link
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 1be2888..54c4833 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1775,6 +1775,27 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
break;
+ case SIOCSIFCAP:
+ VLAN_LOCK();
+ if (TRUNK(ifv) != NULL) {
+ p = PARENT(ifv);
+ VLAN_UNLOCK();
+ if ((p->if_type != IFT_ETHER) &&
+ (ifr->ifr_reqcap & IFCAP_VLAN_HWTAGGING) == 0) {
+ error = EINVAL;
+ break;
+ }
+ error = (*p->if_ioctl)(p, cmd, data);
+ if (error)
+ break;
+ /* Propogate vlan interface capabilities */
+ vlan_trunk_capabilities(p);
+ } else {
+ VLAN_UNLOCK();
+ error = EINVAL;
+ }
+ break;
+
default:
error = EINVAL;
break;
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 4070292..cb39e59 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -84,15 +84,15 @@ __FBSDID("$FreeBSD$");
#define KTR_IGMPV3 KTR_INET
#endif
-static struct igmp_ifinfo *
+static struct igmp_ifsoftc *
igi_alloc_locked(struct ifnet *);
static void igi_delete_locked(const struct ifnet *);
static void igmp_dispatch_queue(struct mbufq *, int, const int);
static void igmp_fasttimo_vnet(void);
-static void igmp_final_leave(struct in_multi *, struct igmp_ifinfo *);
+static void igmp_final_leave(struct in_multi *, struct igmp_ifsoftc *);
static int igmp_handle_state_change(struct in_multi *,
- struct igmp_ifinfo *);
-static int igmp_initial_join(struct in_multi *, struct igmp_ifinfo *);
+ struct igmp_ifsoftc *);
+static int igmp_initial_join(struct in_multi *, struct igmp_ifsoftc *);
static int igmp_input_v1_query(struct ifnet *, const struct ip *,
const struct igmp *);
static int igmp_input_v2_query(struct ifnet *, const struct ip *,
@@ -100,7 +100,7 @@ static int igmp_input_v2_query(struct ifnet *, const struct ip *,
static int igmp_input_v3_query(struct ifnet *, const struct ip *,
/*const*/ struct igmpv3 *);
static int igmp_input_v3_group_query(struct in_multi *,
- struct igmp_ifinfo *, int, /*const*/ struct igmpv3 *);
+ struct igmp_ifsoftc *, int, /*const*/ struct igmpv3 *);
static int igmp_input_v1_report(struct ifnet *, /*const*/ struct ip *,
/*const*/ struct igmp *);
static int igmp_input_v2_report(struct ifnet *, /*const*/ struct ip *,
@@ -112,21 +112,21 @@ static struct mbuf *
#ifdef KTR
static char * igmp_rec_type_to_str(const int);
#endif
-static void igmp_set_version(struct igmp_ifinfo *, const int);
+static void igmp_set_version(struct igmp_ifsoftc *, const int);
static void igmp_slowtimo_vnet(void);
static int igmp_v1v2_queue_report(struct in_multi *, const int);
static void igmp_v1v2_process_group_timer(struct in_multi *, const int);
-static void igmp_v1v2_process_querier_timers(struct igmp_ifinfo *);
+static void igmp_v1v2_process_querier_timers(struct igmp_ifsoftc *);
static void igmp_v2_update_group(struct in_multi *, const int);
-static void igmp_v3_cancel_link_timers(struct igmp_ifinfo *);
-static void igmp_v3_dispatch_general_query(struct igmp_ifinfo *);
+static void igmp_v3_cancel_link_timers(struct igmp_ifsoftc *);
+static void igmp_v3_dispatch_general_query(struct igmp_ifsoftc *);
static struct mbuf *
igmp_v3_encap_report(struct ifnet *, struct mbuf *);
static int igmp_v3_enqueue_group_record(struct mbufq *,
struct in_multi *, const int, const int, const int);
static int igmp_v3_enqueue_filter_change(struct mbufq *,
struct in_multi *);
-static void igmp_v3_process_group_timers(struct igmp_ifinfo *,
+static void igmp_v3_process_group_timers(struct igmp_ifsoftc *,
struct mbufq *, struct mbufq *, struct in_multi *,
const int);
static int igmp_v3_merge_state_changes(struct in_multi *,
@@ -158,13 +158,13 @@ static const struct netisr_handler igmp_nh = {
* * All output is delegated to the netisr.
* Now that Giant has been eliminated, the netisr may be inlined.
* * IN_MULTI_LOCK covers in_multi.
- * * IGMP_LOCK covers igmp_ifinfo and any global variables in this file,
+ * * IGMP_LOCK covers igmp_ifsoftc and any global variables in this file,
* including the output queue.
* * IF_ADDR_LOCK covers if_multiaddrs, which is used for a variety of
* per-link state iterators.
- * * igmp_ifinfo is valid as long as PF_INET is attached to the interface,
+ * * igmp_ifsoftc is valid as long as PF_INET is attached to the interface,
* therefore it is not refcounted.
- * We allow unlocked reads of igmp_ifinfo when accessed via in_multi.
+ * We allow unlocked reads of igmp_ifsoftc when accessed via in_multi.
*
* Reference counting
* * IGMP acquires its own reference every time an in_multi is passed to
@@ -219,7 +219,7 @@ static VNET_DEFINE(int, current_state_timers_running); /* IGMPv1/v2 host
#define V_state_change_timers_running VNET(state_change_timers_running)
#define V_current_state_timers_running VNET(current_state_timers_running)
-static VNET_DEFINE(LIST_HEAD(, igmp_ifinfo), igi_head);
+static VNET_DEFINE(LIST_HEAD(, igmp_ifsoftc), igi_head);
static VNET_DEFINE(struct igmpstat, igmpstat) = {
.igps_version = IGPS_VERSION_3,
.igps_len = sizeof(struct igmpstat),
@@ -412,7 +412,7 @@ out_locked:
}
/*
- * Expose struct igmp_ifinfo to userland, keyed by ifindex.
+ * Expose struct igmp_ifsoftc to userland, keyed by ifindex.
* For use by ifmcstat(8).
*
* SMPng: NOTE: Does an unlocked ifindex space read.
@@ -426,7 +426,7 @@ sysctl_igmp_ifinfo(SYSCTL_HANDLER_ARGS)
int error;
u_int namelen;
struct ifnet *ifp;
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
name = (int *)arg1;
namelen = arg2;
@@ -457,8 +457,18 @@ sysctl_igmp_ifinfo(SYSCTL_HANDLER_ARGS)
LIST_FOREACH(igi, &V_igi_head, igi_link) {
if (ifp == igi->igi_ifp) {
- error = SYSCTL_OUT(req, igi,
- sizeof(struct igmp_ifinfo));
+ struct igmp_ifinfo info;
+
+ info.igi_version = igi->igi_version;
+ info.igi_v1_timer = igi->igi_v1_timer;
+ info.igi_v2_timer = igi->igi_v2_timer;
+ info.igi_v3_timer = igi->igi_v3_timer;
+ info.igi_flags = igi->igi_flags;
+ info.igi_rv = igi->igi_rv;
+ info.igi_qi = igi->igi_qi;
+ info.igi_qri = igi->igi_qri;
+ info.igi_uri = igi->igi_uri;
+ error = SYSCTL_OUT(req, &info, sizeof(info));
break;
}
}
@@ -536,10 +546,10 @@ igmp_ra_alloc(void)
/*
* Attach IGMP when PF_INET is attached to an interface.
*/
-struct igmp_ifinfo *
+struct igmp_ifsoftc *
igmp_domifattach(struct ifnet *ifp)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
CTR3(KTR_IGMPV3, "%s: called for ifp %p(%s)",
__func__, ifp, ifp->if_xname);
@@ -558,14 +568,14 @@ igmp_domifattach(struct ifnet *ifp)
/*
* VIMAGE: assume curvnet set by caller.
*/
-static struct igmp_ifinfo *
+static struct igmp_ifsoftc *
igi_alloc_locked(/*const*/ struct ifnet *ifp)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
IGMP_LOCK_ASSERT();
- igi = malloc(sizeof(struct igmp_ifinfo), M_IGMP, M_NOWAIT|M_ZERO);
+ igi = malloc(sizeof(struct igmp_ifsoftc), M_IGMP, M_NOWAIT|M_ZERO);
if (igi == NULL)
goto out;
@@ -581,7 +591,7 @@ igi_alloc_locked(/*const*/ struct ifnet *ifp)
LIST_INSERT_HEAD(&V_igi_head, igi, igi_link);
- CTR2(KTR_IGMPV3, "allocate igmp_ifinfo for ifp %p(%s)",
+ CTR2(KTR_IGMPV3, "allocate igmp_ifsoftc for ifp %p(%s)",
ifp, ifp->if_xname);
out:
@@ -600,7 +610,7 @@ out:
void
igmp_ifdetach(struct ifnet *ifp)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
struct ifmultiaddr *ifma;
struct in_multi *inm, *tinm;
@@ -647,7 +657,7 @@ igmp_ifdetach(struct ifnet *ifp)
void
igmp_domifdetach(struct ifnet *ifp)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
CTR3(KTR_IGMPV3, "%s: called for ifp %p(%s)",
__func__, ifp, ifp->if_xname);
@@ -663,9 +673,9 @@ igmp_domifdetach(struct ifnet *ifp)
static void
igi_delete_locked(const struct ifnet *ifp)
{
- struct igmp_ifinfo *igi, *tigi;
+ struct igmp_ifsoftc *igi, *tigi;
- CTR3(KTR_IGMPV3, "%s: freeing igmp_ifinfo for ifp %p(%s)",
+ CTR3(KTR_IGMPV3, "%s: freeing igmp_ifsoftc for ifp %p(%s)",
__func__, ifp, ifp->if_xname);
IGMP_LOCK_ASSERT();
@@ -689,7 +699,7 @@ igi_delete_locked(const struct ifnet *ifp)
}
#ifdef INVARIANTS
- panic("%s: igmp_ifinfo not found for ifp %p\n", __func__, ifp);
+ panic("%s: igmp_ifsoftc not found for ifp %p\n", __func__, ifp);
#endif
}
@@ -704,7 +714,7 @@ igmp_input_v1_query(struct ifnet *ifp, const struct ip *ip,
const struct igmp *igmp)
{
struct ifmultiaddr *ifma;
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
struct in_multi *inm;
/*
@@ -724,7 +734,7 @@ igmp_input_v1_query(struct ifnet *ifp, const struct ip *ip,
IGMP_LOCK();
igi = ((struct in_ifinfo *)ifp->if_afdata[AF_INET])->ii_igmp;
- KASSERT(igi != NULL, ("%s: no igmp_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(igi != NULL, ("%s: no igmp_ifsoftc for ifp %p", __func__, ifp));
if (igi->igi_flags & IGIF_LOOPBACK) {
CTR2(KTR_IGMPV3, "ignore v1 query on IGIF_LOOPBACK ifp %p(%s)",
@@ -789,7 +799,7 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
const struct igmp *igmp)
{
struct ifmultiaddr *ifma;
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
struct in_multi *inm;
int is_general_query;
uint16_t timer;
@@ -818,7 +828,7 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
IGMP_LOCK();
igi = ((struct in_ifinfo *)ifp->if_afdata[AF_INET])->ii_igmp;
- KASSERT(igi != NULL, ("%s: no igmp_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(igi != NULL, ("%s: no igmp_ifsoftc for ifp %p", __func__, ifp));
if (igi->igi_flags & IGIF_LOOPBACK) {
CTR2(KTR_IGMPV3, "ignore v2 query on IGIF_LOOPBACK ifp %p(%s)",
@@ -939,7 +949,7 @@ static int
igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip,
/*const*/ struct igmpv3 *igmpv3)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
struct in_multi *inm;
int is_general_query;
uint32_t maxresp, nsrc, qqi;
@@ -1012,7 +1022,7 @@ igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip,
IGMP_LOCK();
igi = ((struct in_ifinfo *)ifp->if_afdata[AF_INET])->ii_igmp;
- KASSERT(igi != NULL, ("%s: no igmp_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(igi != NULL, ("%s: no igmp_ifsoftc for ifp %p", __func__, ifp));
if (igi->igi_flags & IGIF_LOOPBACK) {
CTR2(KTR_IGMPV3, "ignore v3 query on IGIF_LOOPBACK ifp %p(%s)",
@@ -1100,7 +1110,7 @@ out_locked:
* Return <0 if any error occured. Currently this is ignored.
*/
static int
-igmp_input_v3_group_query(struct in_multi *inm, struct igmp_ifinfo *igi,
+igmp_input_v3_group_query(struct in_multi *inm, struct igmp_ifsoftc *igi,
int timer, /*const*/ struct igmpv3 *igmpv3)
{
int retval;
@@ -1245,7 +1255,7 @@ igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip,
IN_MULTI_LOCK();
inm = inm_lookup(ifp, igmp->igmp_group);
if (inm != NULL) {
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
igi = inm->inm_igi;
if (igi == NULL) {
@@ -1369,7 +1379,7 @@ igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip,
IN_MULTI_LOCK();
inm = inm_lookup(ifp, igmp->igmp_group);
if (inm != NULL) {
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
igi = inm->inm_igi;
KASSERT(igi != NULL, ("%s: no igi for ifp %p", __func__, ifp));
@@ -1638,7 +1648,7 @@ igmp_fasttimo_vnet(void)
struct mbufq scq; /* State-change packets */
struct mbufq qrq; /* Query response packets */
struct ifnet *ifp;
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
struct ifmultiaddr *ifma;
struct in_multi *inm;
int loop, uri_fasthz;
@@ -1796,7 +1806,7 @@ igmp_v1v2_process_group_timer(struct in_multi *inm, const int version)
* Note: Unlocked read from igi.
*/
static void
-igmp_v3_process_group_timers(struct igmp_ifinfo *igi,
+igmp_v3_process_group_timers(struct igmp_ifsoftc *igi,
struct mbufq *qrq, struct mbufq *scq,
struct in_multi *inm, const int uri_fasthz)
{
@@ -1943,7 +1953,7 @@ igmp_v3_suppress_group_record(struct in_multi *inm)
* as per Section 7.2.1.
*/
static void
-igmp_set_version(struct igmp_ifinfo *igi, const int version)
+igmp_set_version(struct igmp_ifsoftc *igi, const int version)
{
int old_version_timer;
@@ -1992,7 +2002,7 @@ igmp_set_version(struct igmp_ifinfo *igi, const int version)
* query processing.
*/
static void
-igmp_v3_cancel_link_timers(struct igmp_ifinfo *igi)
+igmp_v3_cancel_link_timers(struct igmp_ifsoftc *igi)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
@@ -2073,7 +2083,7 @@ igmp_v3_cancel_link_timers(struct igmp_ifinfo *igi)
* See Section 7.2.1 of RFC 3376.
*/
static void
-igmp_v1v2_process_querier_timers(struct igmp_ifinfo *igi)
+igmp_v1v2_process_querier_timers(struct igmp_ifsoftc *igi)
{
IGMP_LOCK_ASSERT();
@@ -2169,7 +2179,7 @@ igmp_slowtimo(void)
static void
igmp_slowtimo_vnet(void)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
IGMP_LOCK();
@@ -2265,7 +2275,7 @@ igmp_v1v2_queue_report(struct in_multi *inm, const int type)
int
igmp_change_state(struct in_multi *inm)
{
- struct igmp_ifinfo *igi;
+ struct igmp_ifsoftc *igi;
struct ifnet *ifp;
int error;
@@ -2288,7 +2298,7 @@ igmp_change_state(struct in_multi *inm)
IGMP_LOCK();
igi = ((struct in_ifinfo *)ifp->if_afdata[AF_INET])->ii_igmp;
- KASSERT(igi != NULL, ("%s: no igmp_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(igi != NULL, ("%s: no igmp_ifsoftc for ifp %p", __func__, ifp));
/*
* If we detect a state transition to or from MCAST_UNDEFINED
@@ -2329,7 +2339,7 @@ out_locked:
* initial state of the membership.
*/
static int
-igmp_initial_join(struct in_multi *inm, struct igmp_ifinfo *igi)
+igmp_initial_join(struct in_multi *inm, struct igmp_ifsoftc *igi)
{
struct ifnet *ifp;
struct mbufq *mq;
@@ -2457,7 +2467,7 @@ igmp_initial_join(struct in_multi *inm, struct igmp_ifinfo *igi)
* Issue an intermediate state change during the IGMP life-cycle.
*/
static int
-igmp_handle_state_change(struct in_multi *inm, struct igmp_ifinfo *igi)
+igmp_handle_state_change(struct in_multi *inm, struct igmp_ifsoftc *igi)
{
struct ifnet *ifp;
int retval;
@@ -2516,7 +2526,7 @@ igmp_handle_state_change(struct in_multi *inm, struct igmp_ifinfo *igi)
* to INCLUDE {} for immediate transmission.
*/
static void
-igmp_final_leave(struct in_multi *inm, struct igmp_ifinfo *igi)
+igmp_final_leave(struct in_multi *inm, struct igmp_ifsoftc *igi)
{
int syncstates;
@@ -3308,7 +3318,7 @@ igmp_v3_merge_state_changes(struct in_multi *inm, struct mbufq *scq)
* Respond to a pending IGMPv3 General Query.
*/
static void
-igmp_v3_dispatch_general_query(struct igmp_ifinfo *igi)
+igmp_v3_dispatch_general_query(struct igmp_ifsoftc *igi)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
diff --git a/sys/netinet/igmp_var.h b/sys/netinet/igmp_var.h
index b8e5bf7..5242d07 100644
--- a/sys/netinet/igmp_var.h
+++ b/sys/netinet/igmp_var.h
@@ -46,24 +46,6 @@
* MULTICAST Revision: 3.5.1.3
*/
-#ifndef BURN_BRIDGES
-/*
- * Pre-IGMPV3 igmpstat structure.
- */
-struct oigmpstat {
- u_int igps_rcv_total; /* total IGMP messages received */
- u_int igps_rcv_tooshort; /* received with too few bytes */
- u_int igps_rcv_badsum; /* received with bad checksum */
- u_int igps_rcv_queries; /* received membership queries */
- u_int igps_rcv_badqueries; /* received invalid queries */
- u_int igps_rcv_reports; /* received membership reports */
- u_int igps_rcv_badreports; /* received invalid reports */
- u_int igps_rcv_ourreports; /* received reports for our groups */
- u_int igps_snd_reports; /* sent membership reports */
- u_int igps_rcv_toolong; /* received with too many bytes */
-};
-#endif
-
/*
* IGMPv3 protocol statistics.
*/
@@ -105,19 +87,16 @@ struct igmpstat {
};
#define IGPS_VERSION_3 3 /* as of FreeBSD 8.x */
#define IGPS_VERSION3_LEN 168
-
-#ifdef _KERNEL
-#define IGMPSTAT_ADD(name, val) V_igmpstat.name += (val)
-#define IGMPSTAT_INC(name) IGMPSTAT_ADD(name, 1)
-#endif
-
#ifdef CTASSERT
-CTASSERT(sizeof(struct igmpstat) == 168);
+CTASSERT(sizeof(struct igmpstat) == IGPS_VERSION3_LEN);
#endif
-#ifdef _KERNEL
-#define IGMP_RANDOM_DELAY(X) (random() % (X) + 1)
+/*
+ * Identifiers for IGMP sysctl nodes
+ */
+#define IGMPCTL_STATS 1 /* statistics (read-only) */
+#define IGMP_RANDOM_DELAY(X) (random() % (X) + 1)
#define IGMP_MAX_STATE_CHANGES 24 /* Max pending changes per group */
/*
@@ -186,6 +165,27 @@ CTASSERT(sizeof(struct igmpstat) == 168);
(sizeof(struct ip) + RAOPT_LEN + sizeof(struct igmp_report))
/*
+ * Structure returned by net.inet.igmp.ifinfo sysctl.
+ */
+struct igmp_ifinfo {
+ uint32_t igi_version; /* IGMPv3 Host Compatibility Mode */
+ uint32_t igi_v1_timer; /* IGMPv1 Querier Present timer (s) */
+ uint32_t igi_v2_timer; /* IGMPv2 Querier Present timer (s) */
+ uint32_t igi_v3_timer; /* IGMPv3 General Query (interface) timer (s)*/
+ uint32_t igi_flags; /* IGMP per-interface flags */
+#define IGIF_SILENT 0x00000001 /* Do not use IGMP on this ifp */
+#define IGIF_LOOPBACK 0x00000002 /* Send IGMP reports to loopback */
+ uint32_t igi_rv; /* IGMPv3 Robustness Variable */
+ uint32_t igi_qi; /* IGMPv3 Query Interval (s) */
+ uint32_t igi_qri; /* IGMPv3 Query Response Interval (s) */
+ uint32_t igi_uri; /* IGMPv3 Unsolicited Report Interval (s) */
+};
+
+#ifdef _KERNEL
+#define IGMPSTAT_ADD(name, val) V_igmpstat.name += (val)
+#define IGMPSTAT_INC(name) IGMPSTAT_ADD(name, 1)
+
+/*
* Subsystem lock macros.
* The IGMP lock is only taken with IGMP. Currently it is system-wide.
* VIMAGE: The lock could be pushed to per-VIMAGE granularity in future.
@@ -197,11 +197,28 @@ CTASSERT(sizeof(struct igmpstat) == 168);
#define IGMP_UNLOCK() mtx_unlock(&igmp_mtx)
#define IGMP_UNLOCK_ASSERT() mtx_assert(&igmp_mtx, MA_NOTOWNED)
-struct igmp_ifinfo;
+/*
+ * Per-interface IGMP router version information.
+ */
+struct igmp_ifsoftc {
+ LIST_ENTRY(igmp_ifsoftc) igi_link;
+ struct ifnet *igi_ifp; /* pointer back to interface */
+ uint32_t igi_version; /* IGMPv3 Host Compatibility Mode */
+ uint32_t igi_v1_timer; /* IGMPv1 Querier Present timer (s) */
+ uint32_t igi_v2_timer; /* IGMPv2 Querier Present timer (s) */
+ uint32_t igi_v3_timer; /* IGMPv3 General Query (interface) timer (s)*/
+ uint32_t igi_flags; /* IGMP per-interface flags */
+ uint32_t igi_rv; /* IGMPv3 Robustness Variable */
+ uint32_t igi_qi; /* IGMPv3 Query Interval (s) */
+ uint32_t igi_qri; /* IGMPv3 Query Response Interval (s) */
+ uint32_t igi_uri; /* IGMPv3 Unsolicited Report Interval (s) */
+ SLIST_HEAD(,in_multi) igi_relinmhead; /* released groups */
+ struct mbufq igi_gq; /* general query responses queue */
+};
int igmp_change_state(struct in_multi *);
void igmp_fasttimo(void);
-struct igmp_ifinfo *
+struct igmp_ifsoftc *
igmp_domifattach(struct ifnet *);
void igmp_domifdetach(struct ifnet *);
void igmp_ifdetach(struct ifnet *);
@@ -211,10 +228,4 @@ void igmp_slowtimo(void);
SYSCTL_DECL(_net_inet_igmp);
#endif /* _KERNEL */
-
-/*
- * Identifiers for IGMP sysctl nodes
- */
-#define IGMPCTL_STATS 1 /* statistics (read-only) */
-
#endif
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index ad0482e..f7737ec 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -33,11 +33,24 @@
#ifndef _NETINET_IN_VAR_H_
#define _NETINET_IN_VAR_H_
+/*
+ * Argument structure for SIOCAIFADDR.
+ */
+struct in_aliasreq {
+ char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ struct sockaddr_in ifra_addr;
+ struct sockaddr_in ifra_broadaddr;
+#define ifra_dstaddr ifra_broadaddr
+ struct sockaddr_in ifra_mask;
+ int ifra_vhid;
+};
+
+#ifdef _KERNEL
#include <sys/queue.h>
#include <sys/fnv_hash.h>
#include <sys/tree.h>
-struct igmp_ifinfo;
+struct igmp_ifsoftc;
struct in_multi;
struct lltable;
@@ -46,11 +59,10 @@ struct lltable;
*/
struct in_ifinfo {
struct lltable *ii_llt; /* ARP state */
- struct igmp_ifinfo *ii_igmp; /* IGMP state */
+ struct igmp_ifsoftc *ii_igmp; /* IGMP state */
struct in_multi *ii_allhosts; /* 224.0.0.1 membership */
};
-#if defined(_KERNEL) || defined(_WANT_IFADDR)
/*
* Interface address, Internet version. One of these structures
* is allocated for each Internet address on an interface.
@@ -71,16 +83,7 @@ struct in_ifaddr {
#define ia_broadaddr ia_dstaddr
struct sockaddr_in ia_sockmask; /* reserve space for general netmask */
};
-#endif
-struct in_aliasreq {
- char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
- struct sockaddr_in ifra_addr;
- struct sockaddr_in ifra_broadaddr;
-#define ifra_dstaddr ifra_broadaddr
- struct sockaddr_in ifra_mask;
- int ifra_vhid;
-};
/*
* Given a pointer to an in_ifaddr (ifaddr),
* return a pointer to the addr as a sockaddr_in.
@@ -92,8 +95,6 @@ struct in_aliasreq {
#define IN_LNAOF(in, ifa) \
((ntohl((in).s_addr) & ~((struct in_ifaddr *)(ifa)->ia_subnetmask))
-
-#ifdef _KERNEL
extern u_char inetctlerrmap[];
#define LLTABLE(ifp) \
@@ -194,28 +195,6 @@ struct router_info {
};
/*
- * Per-interface IGMP router version information.
- */
-struct igmp_ifinfo {
- LIST_ENTRY(igmp_ifinfo) igi_link;
- struct ifnet *igi_ifp; /* interface this instance belongs to */
- uint32_t igi_version; /* IGMPv3 Host Compatibility Mode */
- uint32_t igi_v1_timer; /* IGMPv1 Querier Present timer (s) */
- uint32_t igi_v2_timer; /* IGMPv2 Querier Present timer (s) */
- uint32_t igi_v3_timer; /* IGMPv3 General Query (interface) timer (s)*/
- uint32_t igi_flags; /* IGMP per-interface flags */
- uint32_t igi_rv; /* IGMPv3 Robustness Variable */
- uint32_t igi_qi; /* IGMPv3 Query Interval (s) */
- uint32_t igi_qri; /* IGMPv3 Query Response Interval (s) */
- uint32_t igi_uri; /* IGMPv3 Unsolicited Report Interval (s) */
- SLIST_HEAD(,in_multi) igi_relinmhead; /* released groups */
- struct mbufq igi_gq; /* queue of general query responses */
-};
-
-#define IGIF_SILENT 0x00000001 /* Do not use IGMP on this ifp */
-#define IGIF_LOOPBACK 0x00000002 /* Send IGMP reports to loopback */
-
-/*
* IPv4 multicast IGMP-layer source entry.
*/
struct ip_msource {
@@ -293,7 +272,7 @@ struct in_multi {
u_int inm_refcount; /* reference count */
/* New fields for IGMPv3 follow. */
- struct igmp_ifinfo *inm_igi; /* IGMP info */
+ struct igmp_ifsoftc *inm_igi; /* IGMP info */
SLIST_ENTRY(in_multi) inm_nrele; /* to-be-released by IGMP */
struct ip_msource_tree inm_srcs; /* tree of sources */
u_long inm_nsrc; /* # of tree entries */
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 51aa466..7d1551b 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -97,7 +97,7 @@ struct in6_addrlifetime {
struct nd_ifinfo;
struct scope6_id;
struct lltable;
-struct mld_ifinfo;
+struct mld_ifsoftc;
struct in6_ifextra {
counter_u64_t *in6_ifstat;
@@ -105,12 +105,12 @@ struct in6_ifextra {
struct nd_ifinfo *nd_ifinfo;
struct scope6_id *scope6_id;
struct lltable *lltable;
- struct mld_ifinfo *mld_ifinfo;
+ struct mld_ifsoftc *mld_ifinfo;
};
#define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable)
-#if defined(_KERNEL) || defined(_WANT_IFADDR)
+#ifdef _KERNEL
struct in6_ifaddr {
struct ifaddr ia_ifa; /* protocol-independent info */
#define ia_ifp ia_ifa.ifa_ifp
@@ -141,7 +141,7 @@ struct in6_ifaddr {
/* List of in6_ifaddr's. */
TAILQ_HEAD(in6_ifaddrhead, in6_ifaddr);
LIST_HEAD(in6_ifaddrlisthead, in6_ifaddr);
-#endif
+#endif /* _KERNEL */
/* control structure to manage address selection policy */
struct in6_addrpolicy {
@@ -646,7 +646,7 @@ struct in6_multi {
u_int in6m_timer; /* MLD6 listener report timer */
/* New fields for MLDv2 follow. */
- struct mld_ifinfo *in6m_mli; /* MLD info */
+ struct mld_ifsoftc *in6m_mli; /* MLD info */
SLIST_ENTRY(in6_multi) in6m_nrele; /* to-be-released by MLD */
struct ip6_msource_tree in6m_srcs; /* tree of sources */
u_long in6m_nsrc; /* # of tree entries */
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 79e68c9..615fb19 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -102,33 +102,33 @@ __FBSDID("$FreeBSD$");
#define KTR_MLD KTR_INET6
#endif
-static struct mld_ifinfo *
+static struct mld_ifsoftc *
mli_alloc_locked(struct ifnet *);
static void mli_delete_locked(const struct ifnet *);
static void mld_dispatch_packet(struct mbuf *);
static void mld_dispatch_queue(struct mbufq *, int);
-static void mld_final_leave(struct in6_multi *, struct mld_ifinfo *);
+static void mld_final_leave(struct in6_multi *, struct mld_ifsoftc *);
static void mld_fasttimo_vnet(void);
static int mld_handle_state_change(struct in6_multi *,
- struct mld_ifinfo *);
-static int mld_initial_join(struct in6_multi *, struct mld_ifinfo *,
+ struct mld_ifsoftc *);
+static int mld_initial_join(struct in6_multi *, struct mld_ifsoftc *,
const int);
#ifdef KTR
static char * mld_rec_type_to_str(const int);
#endif
-static void mld_set_version(struct mld_ifinfo *, const int);
+static void mld_set_version(struct mld_ifsoftc *, const int);
static void mld_slowtimo_vnet(void);
static int mld_v1_input_query(struct ifnet *, const struct ip6_hdr *,
/*const*/ struct mld_hdr *);
static int mld_v1_input_report(struct ifnet *, const struct ip6_hdr *,
/*const*/ struct mld_hdr *);
-static void mld_v1_process_group_timer(struct mld_ifinfo *,
+static void mld_v1_process_group_timer(struct mld_ifsoftc *,
struct in6_multi *);
-static void mld_v1_process_querier_timers(struct mld_ifinfo *);
+static void mld_v1_process_querier_timers(struct mld_ifsoftc *);
static int mld_v1_transmit_report(struct in6_multi *, const int);
static void mld_v1_update_group(struct in6_multi *, const int);
-static void mld_v2_cancel_link_timers(struct mld_ifinfo *);
-static void mld_v2_dispatch_general_query(struct mld_ifinfo *);
+static void mld_v2_cancel_link_timers(struct mld_ifsoftc *);
+static void mld_v2_dispatch_general_query(struct mld_ifsoftc *);
static struct mbuf *
mld_v2_encap_report(struct ifnet *, struct mbuf *);
static int mld_v2_enqueue_filter_change(struct mbufq *,
@@ -140,11 +140,11 @@ static int mld_v2_input_query(struct ifnet *, const struct ip6_hdr *,
struct mbuf *, const int, const int);
static int mld_v2_merge_state_changes(struct in6_multi *,
struct mbufq *);
-static void mld_v2_process_group_timers(struct mld_ifinfo *,
+static void mld_v2_process_group_timers(struct mld_ifsoftc *,
struct mbufq *, struct mbufq *,
struct in6_multi *, const int);
static int mld_v2_process_group_query(struct in6_multi *,
- struct mld_ifinfo *mli, int, struct mbuf *, const int);
+ struct mld_ifsoftc *mli, int, struct mbuf *, const int);
static int sysctl_mld_gsr(SYSCTL_HANDLER_ARGS);
static int sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS);
@@ -206,7 +206,7 @@ static MALLOC_DEFINE(M_MLD, "mld", "mld state");
* VIMAGE-wide globals.
*/
static VNET_DEFINE(struct timeval, mld_gsrdelay) = {10, 0};
-static VNET_DEFINE(LIST_HEAD(, mld_ifinfo), mli_head);
+static VNET_DEFINE(LIST_HEAD(, mld_ifsoftc), mli_head);
static VNET_DEFINE(int, interface_timers_running6);
static VNET_DEFINE(int, state_change_timers_running6);
static VNET_DEFINE(int, current_state_timers_running6);
@@ -344,7 +344,7 @@ out_locked:
}
/*
- * Expose struct mld_ifinfo to userland, keyed by ifindex.
+ * Expose struct mld_ifsoftc to userland, keyed by ifindex.
* For use by ifmcstat(8).
*
* SMPng: NOTE: Does an unlocked ifindex space read.
@@ -358,7 +358,7 @@ sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS)
int error;
u_int namelen;
struct ifnet *ifp;
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
name = (int *)arg1;
namelen = arg2;
@@ -389,8 +389,17 @@ sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS)
LIST_FOREACH(mli, &V_mli_head, mli_link) {
if (ifp == mli->mli_ifp) {
- error = SYSCTL_OUT(req, mli,
- sizeof(struct mld_ifinfo));
+ struct mld_ifinfo info;
+
+ info.mli_version = mli->mli_version;
+ info.mli_v1_timer = mli->mli_v1_timer;
+ info.mli_v2_timer = mli->mli_v2_timer;
+ info.mli_flags = mli->mli_flags;
+ info.mli_rv = mli->mli_rv;
+ info.mli_qi = mli->mli_qi;
+ info.mli_qri = mli->mli_qri;
+ info.mli_uri = mli->mli_uri;
+ error = SYSCTL_OUT(req, &info, sizeof(info));
break;
}
}
@@ -454,10 +463,10 @@ mld_is_addr_reported(const struct in6_addr *addr)
*
* SMPng: Normally called with IF_AFDATA_LOCK held.
*/
-struct mld_ifinfo *
+struct mld_ifsoftc *
mld_domifattach(struct ifnet *ifp)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
CTR3(KTR_MLD, "%s: called for ifp %p(%s)",
__func__, ifp, if_name(ifp));
@@ -478,14 +487,14 @@ mld_domifattach(struct ifnet *ifp)
/*
* VIMAGE: assume curvnet set by caller.
*/
-static struct mld_ifinfo *
+static struct mld_ifsoftc *
mli_alloc_locked(/*const*/ struct ifnet *ifp)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
MLD_LOCK_ASSERT();
- mli = malloc(sizeof(struct mld_ifinfo), M_MLD, M_NOWAIT|M_ZERO);
+ mli = malloc(sizeof(struct mld_ifsoftc), M_MLD, M_NOWAIT|M_ZERO);
if (mli == NULL)
goto out;
@@ -501,7 +510,7 @@ mli_alloc_locked(/*const*/ struct ifnet *ifp)
LIST_INSERT_HEAD(&V_mli_head, mli, mli_link);
- CTR2(KTR_MLD, "allocate mld_ifinfo for ifp %p(%s)",
+ CTR2(KTR_MLD, "allocate mld_ifsoftc for ifp %p(%s)",
ifp, if_name(ifp));
out:
@@ -522,7 +531,7 @@ out:
void
mld_ifdetach(struct ifnet *ifp)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct ifmultiaddr *ifma;
struct in6_multi *inm, *tinm;
@@ -578,9 +587,9 @@ mld_domifdetach(struct ifnet *ifp)
static void
mli_delete_locked(const struct ifnet *ifp)
{
- struct mld_ifinfo *mli, *tmli;
+ struct mld_ifsoftc *mli, *tmli;
- CTR3(KTR_MLD, "%s: freeing mld_ifinfo for ifp %p(%s)",
+ CTR3(KTR_MLD, "%s: freeing mld_ifsoftc for ifp %p(%s)",
__func__, ifp, if_name(ifp));
MLD_LOCK_ASSERT();
@@ -603,7 +612,7 @@ mli_delete_locked(const struct ifnet *ifp)
}
}
#ifdef INVARIANTS
- panic("%s: mld_ifinfo not found for ifp %p\n", __func__, ifp);
+ panic("%s: mld_ifsoftc not found for ifp %p\n", __func__, ifp);
#endif
}
@@ -619,7 +628,7 @@ mld_v1_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
/*const*/ struct mld_hdr *mld)
{
struct ifmultiaddr *ifma;
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct in6_multi *inm;
int is_general_query;
uint16_t timer;
@@ -678,7 +687,7 @@ mld_v1_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
* Switch to MLDv1 host compatibility mode.
*/
mli = MLD_IFINFO(ifp);
- KASSERT(mli != NULL, ("%s: no mld_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(mli != NULL, ("%s: no mld_ifsoftc for ifp %p", __func__, ifp));
mld_set_version(mli, MLD_VERSION_1);
timer = (ntohs(mld->mld_maxdelay) * PR_FASTHZ) / MLD_TIMER_SCALE;
@@ -795,7 +804,7 @@ static int
mld_v2_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
struct mbuf *m, const int off, const int icmp6len)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct mldv2_query *mld;
struct in6_multi *inm;
uint32_t maxdelay, nsrc, qqi;
@@ -877,7 +886,7 @@ mld_v2_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
MLD_LOCK();
mli = MLD_IFINFO(ifp);
- KASSERT(mli != NULL, ("%s: no mld_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(mli != NULL, ("%s: no mld_ifsoftc for ifp %p", __func__, ifp));
/*
* Discard the v2 query if we're in Compatibility Mode.
@@ -967,7 +976,7 @@ out_locked:
* Return <0 if any error occured. Currently this is ignored.
*/
static int
-mld_v2_process_group_query(struct in6_multi *inm, struct mld_ifinfo *mli,
+mld_v2_process_group_query(struct in6_multi *inm, struct mld_ifsoftc *mli,
int timer, struct mbuf *m0, const int off)
{
struct mldv2_query *mld;
@@ -1171,7 +1180,7 @@ mld_v1_input_report(struct ifnet *ifp, const struct ip6_hdr *ip6,
*/
inm = in6m_lookup_locked(ifp, &mld->mld_addr);
if (inm != NULL) {
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
mli = inm->in6m_mli;
KASSERT(mli != NULL,
@@ -1321,7 +1330,7 @@ mld_fasttimo_vnet(void)
struct mbufq scq; /* State-change packets */
struct mbufq qrq; /* Query response packets */
struct ifnet *ifp;
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct ifmultiaddr *ifma;
struct in6_multi *inm, *tinm;
int uri_fasthz;
@@ -1446,7 +1455,7 @@ out_locked:
* Will update the global pending timer flags.
*/
static void
-mld_v1_process_group_timer(struct mld_ifinfo *mli, struct in6_multi *inm)
+mld_v1_process_group_timer(struct mld_ifsoftc *mli, struct in6_multi *inm)
{
int report_timer_expired;
@@ -1490,7 +1499,7 @@ mld_v1_process_group_timer(struct mld_ifinfo *mli, struct in6_multi *inm)
* Note: Unlocked read from mli.
*/
static void
-mld_v2_process_group_timers(struct mld_ifinfo *mli,
+mld_v2_process_group_timers(struct mld_ifsoftc *mli,
struct mbufq *qrq, struct mbufq *scq,
struct in6_multi *inm, const int uri_fasthz)
{
@@ -1611,7 +1620,7 @@ mld_v2_process_group_timers(struct mld_ifinfo *mli,
* as per Section 9.12.
*/
static void
-mld_set_version(struct mld_ifinfo *mli, const int version)
+mld_set_version(struct mld_ifsoftc *mli, const int version)
{
int old_version_timer;
@@ -1641,7 +1650,7 @@ mld_set_version(struct mld_ifinfo *mli, const int version)
* joined on it; state-change, general-query, and group-query timers.
*/
static void
-mld_v2_cancel_link_timers(struct mld_ifinfo *mli)
+mld_v2_cancel_link_timers(struct mld_ifsoftc *mli)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
@@ -1734,7 +1743,7 @@ mld_slowtimo(void)
static void
mld_slowtimo_vnet(void)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
MLD_LOCK();
@@ -1750,7 +1759,7 @@ mld_slowtimo_vnet(void)
* See Section 9.12 of RFC 3810.
*/
static void
-mld_v1_process_querier_timers(struct mld_ifinfo *mli)
+mld_v1_process_querier_timers(struct mld_ifsoftc *mli)
{
MLD_LOCK_ASSERT();
@@ -1866,7 +1875,7 @@ mld_v1_transmit_report(struct in6_multi *in6m, const int type)
int
mld_change_state(struct in6_multi *inm, const int delay)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct ifnet *ifp;
int error;
@@ -1891,7 +1900,7 @@ mld_change_state(struct in6_multi *inm, const int delay)
MLD_LOCK();
mli = MLD_IFINFO(ifp);
- KASSERT(mli != NULL, ("%s: no mld_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(mli != NULL, ("%s: no mld_ifsoftc for ifp %p", __func__, ifp));
/*
* If we detect a state transition to or from MCAST_UNDEFINED
@@ -1934,7 +1943,7 @@ out_locked:
* initial state change for delay ticks (in units of PR_FASTHZ).
*/
static int
-mld_initial_join(struct in6_multi *inm, struct mld_ifinfo *mli,
+mld_initial_join(struct in6_multi *inm, struct mld_ifsoftc *mli,
const int delay)
{
struct ifnet *ifp;
@@ -2083,7 +2092,7 @@ mld_initial_join(struct in6_multi *inm, struct mld_ifinfo *mli,
* Issue an intermediate state change during the life-cycle.
*/
static int
-mld_handle_state_change(struct in6_multi *inm, struct mld_ifinfo *mli)
+mld_handle_state_change(struct in6_multi *inm, struct mld_ifsoftc *mli)
{
struct ifnet *ifp;
int retval;
@@ -2147,7 +2156,7 @@ mld_handle_state_change(struct in6_multi *inm, struct mld_ifinfo *mli)
* to INCLUDE {} for immediate transmission.
*/
static void
-mld_final_leave(struct in6_multi *inm, struct mld_ifinfo *mli)
+mld_final_leave(struct in6_multi *inm, struct mld_ifsoftc *mli)
{
int syncstates;
#ifdef KTR
@@ -2963,7 +2972,7 @@ mld_v2_merge_state_changes(struct in6_multi *inm, struct mbufq *scq)
* Respond to a pending MLDv2 General Query.
*/
static void
-mld_v2_dispatch_general_query(struct mld_ifinfo *mli)
+mld_v2_dispatch_general_query(struct mld_ifsoftc *mli)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
diff --git a/sys/netinet6/mld6_var.h b/sys/netinet6/mld6_var.h
index a4e001c..be7e903 100644
--- a/sys/netinet6/mld6_var.h
+++ b/sys/netinet6/mld6_var.h
@@ -35,31 +35,6 @@
* implementation-specific definitions.
*/
-#ifdef _KERNEL
-
-/*
- * Per-link MLD state.
- */
-struct mld_ifinfo {
- LIST_ENTRY(mld_ifinfo) mli_link;
- struct ifnet *mli_ifp; /* interface this instance belongs to */
- uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
- uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
- uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
- uint32_t mli_flags; /* MLD per-interface flags */
- uint32_t mli_rv; /* MLDv2 Robustness Variable */
- uint32_t mli_qi; /* MLDv2 Query Interval (s) */
- uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
- uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
- SLIST_HEAD(,in6_multi) mli_relinmhead; /* released groups */
- struct mbufq mli_gq; /* queue of general query responses */
-};
-#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */
-#define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */
-
-#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
-#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */
-
/*
* MLD per-group states.
*/
@@ -129,6 +104,44 @@ struct mld_ifinfo {
sizeof(struct icmp6_hdr))
/*
+ * Structure returned by net.inet6.mld.ifinfo.
+ */
+struct mld_ifinfo {
+ uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
+ uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
+ uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
+ uint32_t mli_flags; /* MLD per-interface flags */
+#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */
+#define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */
+ uint32_t mli_rv; /* MLDv2 Robustness Variable */
+ uint32_t mli_qi; /* MLDv2 Query Interval (s) */
+ uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
+ uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
+};
+
+#ifdef _KERNEL
+/*
+ * Per-link MLD state.
+ */
+struct mld_ifsoftc {
+ LIST_ENTRY(mld_ifsoftc) mli_link;
+ struct ifnet *mli_ifp; /* interface this instance belongs to */
+ uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
+ uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
+ uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
+ uint32_t mli_flags; /* MLD per-interface flags */
+ uint32_t mli_rv; /* MLDv2 Robustness Variable */
+ uint32_t mli_qi; /* MLDv2 Query Interval (s) */
+ uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
+ uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
+ SLIST_HEAD(,in6_multi) mli_relinmhead; /* released groups */
+ struct mbufq mli_gq; /* queue of general query responses */
+};
+
+#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
+#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */
+
+/*
* Subsystem lock macros.
* The MLD lock is only taken with MLD. Currently it is system-wide.
* VIMAGE: The lock could be pushed to per-VIMAGE granularity in future.
@@ -147,7 +160,7 @@ struct mld_ifinfo {
(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->mld_ifinfo)
int mld_change_state(struct in6_multi *, const int);
-struct mld_ifinfo *
+struct mld_ifsoftc *
mld_domifattach(struct ifnet *);
void mld_domifdetach(struct ifnet *);
void mld_fasttimo(void);
diff --git a/sys/powerpc/powermac/powermac_thermal.c b/sys/powerpc/powermac/powermac_thermal.c
index 8b9462c..250c9f0 100644
--- a/sys/powerpc/powermac/powermac_thermal.c
+++ b/sys/powerpc/powermac/powermac_thermal.c
@@ -42,6 +42,9 @@ __FBSDID("$FreeBSD$");
#include "powermac_thermal.h"
+/* A 10 second timer for spinning down fans. */
+#define FAN_HYSTERESIS_TIMER 10
+
static void fan_management_proc(void);
static void pmac_therm_manage_fans(void);
@@ -63,6 +66,7 @@ static MALLOC_DEFINE(M_PMACTHERM, "pmactherm", "Powermac Thermal Management");
struct pmac_fan_le {
struct pmac_fan *fan;
int last_val;
+ int timer;
SLIST_ENTRY(pmac_fan_le) entries;
};
struct pmac_sens_le {
@@ -95,6 +99,7 @@ pmac_therm_manage_fans(void)
struct pmac_sens_le *sensor;
struct pmac_fan_le *fan;
int average_excess, max_excess_zone, frac_excess;
+ int fan_speed;
int nsens, nsens_zone;
int temp;
@@ -137,10 +142,11 @@ pmac_therm_manage_fans(void)
nsens = nsens_zone = 0;
average_excess = max_excess_zone = 0;
SLIST_FOREACH(sensor, &sensors, entries) {
- frac_excess = (sensor->last_val -
+ temp = imin(sensor->last_val,
+ sensor->sensor->max_temp);
+ frac_excess = (temp -
sensor->sensor->target_temp)*100 /
- (sensor->sensor->max_temp -
- sensor->sensor->target_temp);
+ (sensor->sensor->max_temp - temp + 1);
if (frac_excess < 0)
frac_excess = 0;
if (sensor->sensor->zone == fan->fan->zone) {
@@ -166,9 +172,21 @@ pmac_therm_manage_fans(void)
* Scale the fan linearly in the max temperature in its
* thermal zone.
*/
- fan->fan->set(fan->fan, max_excess_zone *
+ max_excess_zone = imin(max_excess_zone, 100);
+ fan_speed = max_excess_zone *
(fan->fan->max_rpm - fan->fan->min_rpm)/100 +
- fan->fan->min_rpm);
+ fan->fan->min_rpm;
+ if (fan_speed >= fan->last_val) {
+ fan->timer = FAN_HYSTERESIS_TIMER;
+ fan->last_val = fan_speed;
+ } else {
+ fan->timer--;
+ if (fan->timer == 0) {
+ fan->last_val = fan_speed;
+ fan->timer = FAN_HYSTERESIS_TIMER;
+ }
+ }
+ fan->fan->set(fan->fan, fan->last_val);
}
}
diff --git a/sys/powerpc/ps3/ps3_syscons.c b/sys/powerpc/ps3/ps3_syscons.c
index c2d237f..521690c 100644
--- a/sys/powerpc/ps3/ps3_syscons.c
+++ b/sys/powerpc/ps3/ps3_syscons.c
@@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$");
#include "ps3-hvcall.h"
-#define PS3FB_SIZE (4*1024*1024)
-
#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET 0x0100
#define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x0101
#define L1GPU_DISPLAY_SYNC_HSYNC 1
@@ -138,8 +136,8 @@ ps3fb_remap(void)
0,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC,
1,L1GPU_DISPLAY_SYNC_VSYNC,0,0);
- lv1_gpu_memory_allocate(PS3FB_SIZE, 0, 0, 0, 0, &sc->sc_fbhandle,
- &fb_paddr);
+ lv1_gpu_memory_allocate(roundup2(sc->fb_info.fb_size, 1024*1024),
+ 0, 0, 0, 0, &sc->sc_fbhandle, &fb_paddr);
lv1_gpu_context_allocate(sc->sc_fbhandle, 0, &sc->sc_fbcontext,
&sc->sc_dma_control, &sc->sc_driver_info, &sc->sc_reports,
&sc->sc_reports_size);
@@ -150,7 +148,7 @@ ps3fb_remap(void)
L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0);
sc->fb_info.fb_pbase = fb_paddr;
- for (va = 0; va < PS3FB_SIZE; va += PAGE_SIZE)
+ for (va = 0; va < sc->fb_info.fb_size; va += PAGE_SIZE)
pmap_kenter_attr(0x10000000 + va, fb_paddr + va,
VM_MEMATTR_WRITE_COMBINING);
sc->fb_info.fb_flags &= ~FB_FLAG_NOWRITE;
@@ -168,6 +166,8 @@ ps3fb_init(struct vt_device *vd)
sc->fb_info.fb_depth = 32;
sc->fb_info.fb_height = 480;
sc->fb_info.fb_width = 720;
+ TUNABLE_INT_FETCH("hw.ps3fb.height", &sc->fb_info.fb_height);
+ TUNABLE_INT_FETCH("hw.ps3fb.width", &sc->fb_info.fb_width);
sc->fb_info.fb_stride = sc->fb_info.fb_width*4;
sc->fb_info.fb_size = sc->fb_info.fb_height * sc->fb_info.fb_stride;
sc->fb_info.fb_bpp = sc->fb_info.fb_stride / sc->fb_info.fb_width * 8;
diff --git a/sys/x86/acpica/acpi_wakeup.c b/sys/x86/acpica/acpi_wakeup.c
index 70c8d6b..e8782c2 100644
--- a/sys/x86/acpica/acpi_wakeup.c
+++ b/sys/x86/acpica/acpi_wakeup.c
@@ -30,6 +30,11 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#if defined(__amd64__)
+#define DEV_APIC
+#else
+#include "opt_apic.h"
+#endif
#ifdef __i386__
#include "opt_npx.h"
#endif
@@ -55,8 +60,10 @@ __FBSDID("$FreeBSD$");
#include <machine/specialreg.h>
#include <machine/md_var.h>
+#ifdef DEV_APIC
#include <x86/apicreg.h>
#include <x86/apicvar.h>
+#endif
#ifdef SMP
#include <machine/smp.h>
#include <machine/vmparam.h>
@@ -271,7 +278,9 @@ acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result,
initializecpu();
PCPU_SET(switchtime, 0);
PCPU_SET(switchticks, ticks);
+#ifdef DEV_APIC
lapic_xapic_mode();
+#endif
#ifdef SMP
if (!CPU_EMPTY(&suspcpus))
acpi_wakeup_cpus(sc);
diff --git a/sys/x86/iommu/busdma_dmar.c b/sys/x86/iommu/busdma_dmar.c
index 698a791..4efd7b8 100644
--- a/sys/x86/iommu/busdma_dmar.c
+++ b/sys/x86/iommu/busdma_dmar.c
@@ -98,6 +98,8 @@ dmar_get_requester(device_t dev, uint16_t *rid)
devclass_t pci_class;
device_t l, pci, pcib, pcip, pcibp, requester;
int cap_offset;
+ uint16_t pcie_flags;
+ bool bridge_is_pcie;
pci_class = devclass_find("pci");
l = requester = dev;
@@ -144,13 +146,30 @@ dmar_get_requester(device_t dev, uint16_t *rid)
} else {
/*
* Device is not PCIe, it cannot be seen as a
- * requester by DMAR unit.
+ * requester by DMAR unit. Check whether the
+ * bridge is PCIe.
*/
- requester = pcibp;
+ bridge_is_pcie = pci_find_cap(pcib, PCIY_EXPRESS,
+ &cap_offset) == 0;
+ requester = pcib;
- /* Check whether the bus above the bridge is PCIe. */
- if (pci_find_cap(pcibp, PCIY_EXPRESS,
- &cap_offset) == 0) {
+ /*
+ * Check for a buggy PCIe/PCI bridge that
+ * doesn't report the express capability. If
+ * the bridge above it is express but isn't a
+ * PCI bridge, then we know pcib is actually a
+ * PCIe/PCI bridge.
+ */
+ if (!bridge_is_pcie && pci_find_cap(pcibp,
+ PCIY_EXPRESS, &cap_offset) == 0) {
+ pcie_flags = pci_read_config(pcibp,
+ cap_offset + PCIER_FLAGS, 2);
+ if ((pcie_flags & PCIEM_FLAGS_TYPE) !=
+ PCIEM_TYPE_PCI_BRIDGE)
+ bridge_is_pcie = true;
+ }
+
+ if (bridge_is_pcie) {
/*
* The current device is not PCIe, but
* the bridge above it is. This is a
@@ -168,6 +187,7 @@ dmar_get_requester(device_t dev, uint16_t *rid)
* non-taken transactions.
*/
*rid = PCI_RID(pci_get_bus(l), 0, 0);
+ l = pcibp;
} else {
/*
* Neither the device nor the bridge
@@ -177,8 +197,8 @@ dmar_get_requester(device_t dev, uint16_t *rid)
* requester ID.
*/
*rid = pci_get_rid(pcib);
+ l = pcib;
}
- l = pcibp;
}
}
return (requester);
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index ef246a9..6ab8206 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -1612,7 +1612,6 @@ OLD_FILES+=usr/share/man/man8/freebsd-update.8.gz
.endif
.if ${MK_GAMES} == no
-OLD_FILES+=usr/bin/bcd
OLD_FILES+=usr/bin/caesar
OLD_FILES+=usr/bin/factor
OLD_FILES+=usr/bin/fortune
@@ -1620,7 +1619,6 @@ OLD_FILES+=usr/bin/grdc
OLD_FILES+=usr/bin/morse
OLD_FILES+=usr/bin/number
OLD_FILES+=usr/bin/pom
-OLD_FILES+=usr/bin/ppt
OLD_FILES+=usr/bin/primes
OLD_FILES+=usr/bin/random
OLD_FILES+=usr/bin/rot13
@@ -1644,7 +1642,6 @@ OLD_FILES+=usr/share/games/fortune/zippy
OLD_FILES+=usr/share/games/fortune/zippy.dat
OLD_DIRS+=usr/share/games/fortune
OLD_DIRS+=usr/share/games
-OLD_FILES+=usr/share/man/man6/bcd.6.gz
OLD_FILES+=usr/share/man/man6/caesar.6.gz
OLD_FILES+=usr/share/man/man6/factor.6.gz
OLD_FILES+=usr/share/man/man6/fortune.6.gz
@@ -1652,7 +1649,6 @@ OLD_FILES+=usr/share/man/man6/grdc.6.gz
OLD_FILES+=usr/share/man/man6/morse.6.gz
OLD_FILES+=usr/share/man/man6/number.6.gz
OLD_FILES+=usr/share/man/man6/pom.6.gz
-OLD_FILES+=usr/share/man/man6/ppt.6.gz
OLD_FILES+=usr/share/man/man6/primes.6.gz
OLD_FILES+=usr/share/man/man6/random.6.gz
OLD_FILES+=usr/share/man/man6/rot13.6.gz
diff --git a/usr.bin/mkimg/Makefile b/usr.bin/mkimg/Makefile
index c8fdb7d..d635924 100644
--- a/usr.bin/mkimg/Makefile
+++ b/usr.bin/mkimg/Makefile
@@ -6,7 +6,7 @@ PROG= mkimg
SRCS= format.c image.c mkimg.c scheme.c
MAN= mkimg.1
-MKIMG_VERSION=20141211
+MKIMG_VERSION=20150222
mkimg.o: Makefile
CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION}
diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1
index 56cd605..3b1d63e 100644
--- a/usr.bin/mkimg/mkimg.1
+++ b/usr.bin/mkimg/mkimg.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 27, 2014
+.Dd February 22, 2015
.Dt MKIMG 1
.Os
.Sh NAME
@@ -37,13 +37,12 @@
.Op Fl S Ar secsz
.Op Fl T Ar tracksz
.Op Fl b Ar bootcode
+.Op Fl c Ar capacity
.Op Fl f Ar format
.Op Fl o Ar outfile
.Op Fl v
.Op Fl y
-.Fl s Ar scheme
-.Fl p Ar partition
-.Op Fl p Ar partition ...
+.Op Fl s Ar scheme Op Fl p Ar partition ...
.Nm
.Ar --formats | --schemes | --version
.Sh DESCRIPTION
@@ -109,13 +108,29 @@ utility will use the (physical) block size to determine the start of
partitions and to round the size of the disk image.
.Pp
The
-.Op Fl v
+.Fl c
+option can be used to specify a minimal capacity for the disk image.
+Use this option without the
+.Fl s
+and
+.Fl p
+options to create an empty disk image with the given (virtual) size.
+An empty partition table can be written to the disk when specifying a
+partitioning scheme with the
+.Fl s
+option, but without specifying any partitions.
+When the size required to for all the partitions is larger than the
+given capacity, then the disk image will be larger than the capacity
+given.
+.Pp
+The
+.Fl v
option increases the level of output that the
.Nm
utility prints.
.Pp
The
-.Op Fl y
+.Fl y
option is used for testing purposes only and is not to be used in production.
When present, the
.Nm
diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index b55ee7e..5a4b9f9 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -60,6 +60,8 @@ static struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
+static uint64_t capacity;
+
struct partlisthead partlist = STAILQ_HEAD_INITIALIZER(partlist);
u_int nparts = 0;
@@ -147,6 +149,7 @@ usage(const char *why)
fprintf(stderr, "\t--version\t- show version information\n");
fputc('\n', stderr);
fprintf(stderr, "\t-b <file>\t- file containing boot code\n");
+ fprintf(stderr, "\t-c <num>\t- capacity (in bytes) of the disk\n");
fprintf(stderr, "\t-f <format>\n");
fprintf(stderr, "\t-o <file>\t- file to write image into\n");
fprintf(stderr, "\t-p <partition>\n");
@@ -179,7 +182,7 @@ usage(const char *why)
}
static int
-parse_number(u_int *valp, u_int min, u_int max, const char *arg)
+parse_uint32(uint32_t *valp, uint32_t min, uint32_t max, const char *arg)
{
uint64_t val;
@@ -187,7 +190,20 @@ parse_number(u_int *valp, u_int min, u_int max, const char *arg)
return (errno);
if (val > UINT_MAX || val < (uint64_t)min || val > (uint64_t)max)
return (EINVAL);
- *valp = (u_int)val;
+ *valp = (uint32_t)val;
+ return (0);
+}
+
+static int
+parse_uint64(uint64_t *valp, uint64_t min, uint64_t max, const char *arg)
+{
+ uint64_t val;
+
+ if (expand_number(arg, &val) == -1)
+ return (errno);
+ if (val < min || val > max)
+ return (EINVAL);
+ *valp = val;
return (0);
}
@@ -376,6 +392,17 @@ mkimg_uuid(struct uuid *uuid)
memcpy(uuid, gen, sizeof(uuid_t));
}
+static int
+capacity_resize(lba_t end)
+{
+ lba_t capsz;
+
+ capsz = (capacity + secsz - 1) / secsz;
+ if (end >= capsz)
+ return (0);
+ return (image_set_size(capsz));
+}
+
static void
mkimg(void)
{
@@ -437,12 +464,14 @@ mkimg(void)
block = scheme_metadata(SCHEME_META_IMG_END, block);
error = image_set_size(block);
if (!error)
+ error = capacity_resize(block);
+ if (!error)
error = format_resize(block);
if (error)
errc(EX_IOERR, error, "image sizing");
block = image_get_size();
ncyls = block / (nsecs * nheads);
- error = (scheme_write(block));
+ error = scheme_write(block);
if (error)
errc(EX_IOERR, error, "writing metadata");
}
@@ -455,7 +484,7 @@ main(int argc, char *argv[])
bcfd = -1;
outfd = 1; /* Write to stdout by default */
- while ((c = getopt_long(argc, argv, "b:f:o:p:s:vyH:P:S:T:",
+ while ((c = getopt_long(argc, argv, "b:c:f:o:p:s:vyH:P:S:T:",
longopts, NULL)) != -1) {
switch (c) {
case 'b': /* BOOT CODE */
@@ -465,6 +494,11 @@ main(int argc, char *argv[])
if (bcfd == -1)
err(EX_UNAVAILABLE, "%s", optarg);
break;
+ case 'c': /* CAPACITY */
+ error = parse_uint64(&capacity, 1, OFF_MAX, optarg);
+ if (error)
+ errc(EX_DATAERR, error, "capacity in bytes");
+ break;
case 'f': /* OUTPUT FORMAT */
if (format_selected() != NULL)
usage("multiple formats given");
@@ -499,26 +533,26 @@ main(int argc, char *argv[])
verbose++;
break;
case 'H': /* GEOMETRY: HEADS */
- error = parse_number(&nheads, 1, 255, optarg);
+ error = parse_uint32(&nheads, 1, 255, optarg);
if (error)
errc(EX_DATAERR, error, "number of heads");
break;
case 'P': /* GEOMETRY: PHYSICAL SECTOR SIZE */
- error = parse_number(&blksz, 512, INT_MAX+1U, optarg);
+ error = parse_uint32(&blksz, 512, INT_MAX+1U, optarg);
if (error == 0 && !pwr_of_two(blksz))
error = EINVAL;
if (error)
errc(EX_DATAERR, error, "physical sector size");
break;
case 'S': /* GEOMETRY: LOGICAL SECTOR SIZE */
- error = parse_number(&secsz, 512, INT_MAX+1U, optarg);
+ error = parse_uint32(&secsz, 512, INT_MAX+1U, optarg);
if (error == 0 && !pwr_of_two(secsz))
error = EINVAL;
if (error)
errc(EX_DATAERR, error, "logical sector size");
break;
case 'T': /* GEOMETRY: TRACK SIZE */
- error = parse_number(&nsecs, 1, 63, optarg);
+ error = parse_uint32(&nsecs, 1, 63, optarg);
if (error)
errc(EX_DATAERR, error, "track size");
break;
@@ -541,9 +575,9 @@ main(int argc, char *argv[])
if (argc > optind)
usage("trailing arguments");
- if (scheme_selected() == NULL)
+ if (scheme_selected() == NULL && nparts > 0)
usage("no scheme");
- if (nparts == 0)
+ if (nparts == 0 && capacity == 0)
usage("no partitions");
if (secsz > blksz) {
@@ -577,8 +611,9 @@ main(int argc, char *argv[])
fprintf(stderr, "Sectors per track: %u\n", nsecs);
fprintf(stderr, "Number of heads: %u\n", nheads);
fputc('\n', stderr);
- fprintf(stderr, "Partitioning scheme: %s\n",
- scheme_selected()->name);
+ if (scheme_selected())
+ fprintf(stderr, "Partitioning scheme: %s\n",
+ scheme_selected()->name);
fprintf(stderr, "Output file format: %s\n",
format_selected()->name);
fputc('\n', stderr);
diff --git a/usr.bin/mkimg/scheme.c b/usr.bin/mkimg/scheme.c
index ff5e201..336f953 100644
--- a/usr.bin/mkimg/scheme.c
+++ b/usr.bin/mkimg/scheme.c
@@ -31,8 +31,10 @@ __FBSDID("$FreeBSD$");
#include <sys/linker_set.h>
#include <sys/queue.h>
#include <sys/stat.h>
+#include <assert.h>
#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -104,7 +106,7 @@ scheme_bootcode(int fd)
{
struct stat sb;
- if (scheme->bootcode == 0)
+ if (scheme == NULL || scheme->bootcode == 0)
return (ENXIO);
if (fstat(fd, &sb) == -1)
@@ -130,6 +132,8 @@ scheme_check_part(struct part *p)
struct mkimg_alias *iter;
enum alias alias;
+ assert(scheme != NULL);
+
/* Check the partition type alias */
alias = scheme_parse_alias(p->alias);
if (alias == ALIAS_NONE)
@@ -158,29 +162,26 @@ u_int
scheme_max_parts(void)
{
- return (scheme->nparts);
+ return ((scheme == NULL) ? 0 : scheme->nparts);
}
u_int
scheme_max_secsz(void)
{
- return (scheme->maxsecsz);
+ return ((scheme == NULL) ? INT_MAX+1U : scheme->maxsecsz);
}
lba_t
scheme_metadata(u_int where, lba_t start)
{
- return (scheme->metadata(where, start));
+ return ((scheme == NULL) ? start : scheme->metadata(where, start));
}
int
scheme_write(lba_t end)
{
- int error;
- end = image_get_size();
- error = scheme->write(end, bootcode);
- return (error);
+ return ((scheme == NULL) ? 0 : scheme->write(end, bootcode));
}
diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile
index 89c8e03..9c70eb4 100644
--- a/usr.bin/netstat/Makefile
+++ b/usr.bin/netstat/Makefile
@@ -41,4 +41,6 @@ LIBADD+= netgraph
CFLAGS+=-DNETGRAPH
.endif
+LIBADD+= xo
+
.include <bsd.prog.mk>
diff --git a/usr.bin/netstat/bpf.c b/usr.bin/netstat/bpf.c
index 2ffeacb..b48f9a1 100644
--- a/usr.bin/netstat/bpf.c
+++ b/usr.bin/netstat/bpf.c
@@ -46,8 +46,10 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "netstat.h"
@@ -67,7 +69,7 @@ bpf_pidname(pid_t pid)
size = sizeof(newkp);
error = sysctl(mib, 4, &newkp, &size, NULL, 0);
if (error < 0) {
- warn("kern.proc.pid failed");
+ xo_warn("kern.proc.pid failed");
return (strdup("??????"));
}
return (strdup(newkp.ki_comm));
@@ -86,6 +88,21 @@ bpf_flags(struct xbpf_d *bd, char *flagbuf)
*flagbuf++ = bd->bd_async ? 'a' : '-';
*flagbuf++ = bd->bd_locked ? 'l' : '-';
*flagbuf++ = '\0';
+
+ if (bd->bd_promisc)
+ xo_emit("{e:promiscuous/}");
+ if (bd->bd_immediate)
+ xo_emit("{e:immediate/}");
+ if (bd->bd_hdrcmplt)
+ xo_emit("{e:header-complete/}");
+ xo_emit("{e:direction}", (bd->bd_direction == BPF_D_IN) ? "input" :
+ (bd->bd_direction == BPF_D_OUT) ? "output" : "bidirectional");
+ if (bd->bd_feedback)
+ xo_emit("{e:feedback/}");
+ if (bd->bd_async)
+ xo_emit("{e:async/}");
+ if (bd->bd_locked)
+ xo_emit("{e:locked/}");
}
void
@@ -99,44 +116,55 @@ bpf_stats(char *ifname)
bzero(&zerostat, sizeof(zerostat));
if (sysctlbyname("net.bpf.stats", NULL, NULL,
&zerostat, sizeof(zerostat)) < 0)
- warn("failed to zero bpf counters");
+ xo_warn("failed to zero bpf counters");
return;
}
if (sysctlbyname("net.bpf.stats", NULL, &size,
NULL, 0) < 0) {
- warn("net.bpf.stats");
+ xo_warn("net.bpf.stats");
return;
}
if (size == 0)
return;
bd = malloc(size);
if (bd == NULL) {
- warn("malloc failed");
+ xo_warn("malloc failed");
return;
}
if (sysctlbyname("net.bpf.stats", bd, &size,
NULL, 0) < 0) {
- warn("net.bpf.stats");
+ xo_warn("net.bpf.stats");
free(bd);
return;
}
- (void) printf("%5s %6s %7s %9s %9s %9s %5s %5s %s\n",
- "Pid", "Netif", "Flags", "Recv", "Drop", "Match", "Sblen",
- "Hblen", "Command");
+ xo_emit("{T:/%5s} {T:/%6s} {T:/%7s} {T:/%9s} {T:/%9s} {T:/%9s} "
+ "{T:/%5s} {T:/%5s} {T:/%s}\n",
+ "Pid", "Netif", "Flags", "Recv", "Drop", "Match",
+ "Sblen", "Hblen", "Command");
+ xo_open_container("bpf-statistics");
+ xo_open_list("bpf-entry");
for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
if (d->bd_structsize != sizeof(*d)) {
- warnx("bpf_stats_extended: version mismatch");
+ xo_warnx("bpf_stats_extended: version mismatch");
return;
}
if (ifname && strcmp(ifname, d->bd_ifname) != 0)
continue;
- bpf_flags(d, flagbuf);
+ xo_open_instance("bpf-entry");
pname = bpf_pidname(d->bd_pid);
- (void) printf("%5d %6s %7s %9ju %9ju %9ju %5d %5d %s\n",
- d->bd_pid, d->bd_ifname, flagbuf,
- d->bd_rcount, d->bd_dcount, d->bd_fcount,
- d->bd_slen, d->bd_hlen, pname);
+ xo_emit("{k:pid/%5d} {k:interface-name/%6s} ",
+ d->bd_pid, d->bd_ifname);
+ bpf_flags(d, flagbuf);
+ xo_emit("{d:flags/%7s} {:received-packets/%9ju} "
+ "{:dropped-packets/%9ju} {:filter-packets/%9ju} "
+ "{:store-buffer-length/%5d} {:hold-buffer-length/%5d} "
+ "{:process/%s}\n",
+ flagbuf, (uintmax_t)d->bd_rcount, (uintmax_t)d->bd_dcount,
+ (uintmax_t)d->bd_fcount, d->bd_slen, d->bd_hlen, pname);
free(pname);
+ xo_close_instance("bpf-entry");
}
+ xo_close_list("bpf-entry");
+ xo_close_container("bpf-statistics");
free(bd);
}
diff --git a/usr.bin/netstat/flowtable.c b/usr.bin/netstat/flowtable.c
index a3d5dd5..a232d80 100644
--- a/usr.bin/netstat/flowtable.c
+++ b/usr.bin/netstat/flowtable.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdbool.h>
#include "netstat.h"
/*
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index a4c86be..002567b 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "netstat.h"
@@ -98,14 +99,38 @@ static const char* pfsyncacts[] = {
/* PFSYNC_ACT_EOF */ "end of frame mark",
};
+static const char* pfsyncacts_name[] = {
+ /* PFSYNC_ACT_CLR */ "clear-all-request",
+ /* PFSYNC_ACT_INS */ "state-insert",
+ /* PFSYNC_ACT_INS_ACK */ "state-inserted-ack",
+ /* PFSYNC_ACT_UPD */ "state-update",
+ /* PFSYNC_ACT_UPD_C */ "compressed-state-update",
+ /* PFSYNC_ACT_UPD_REQ */ "uncompressed-state-request",
+ /* PFSYNC_ACT_DEL */ "state-delete",
+ /* PFSYNC_ACT_DEL_C */ "compressed-state-delete",
+ /* PFSYNC_ACT_INS_F */ "fragment-insert",
+ /* PFSYNC_ACT_DEL_F */ "fragment-delete",
+ /* PFSYNC_ACT_BUS */ "bulk-update-mark",
+ /* PFSYNC_ACT_TDB */ "TDB-replay-counter-update",
+ /* PFSYNC_ACT_EOF */ "end-of-frame-mark",
+};
+
static void
-pfsync_acts_stats(const char *fmt, uint64_t *a)
+pfsync_acts_stats(const char *list, const char *desc, uint64_t *a)
{
int i;
- for (i = 0; i < PFSYNC_ACT_MAX; i++, a++)
- if (*a || sflag <= 1)
- printf(fmt, *a, pfsyncacts[i], plural(*a));
+ xo_open_list(list);
+ for (i = 0; i < PFSYNC_ACT_MAX; i++, a++) {
+ if (*a || sflag <= 1) {
+ xo_open_instance(list);
+ xo_emit("\t\t{e:name}{:count/%ju} {N:/%s%s %s}\n",
+ pfsyncacts_name[i], (uintmax_t)(*a),
+ pfsyncacts[i], plural(*a), desc);
+ xo_close_instance(list);
+ }
+ }
+ xo_close_list(list);
}
/*
@@ -129,32 +154,50 @@ pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
} else
kread(off, &pfsyncstat, len);
- printf("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
+ xo_open_container(name);
#define p(f, m) if (pfsyncstat.f || sflag <= 1) \
- printf(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
+ xo_emit(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
- p(pfsyncs_ipackets, "\t%ju packet%s received (IPv4)\n");
- p(pfsyncs_ipackets6, "\t%ju packet%s received (IPv6)\n");
- pfsync_acts_stats("\t %ju %s%s received\n",
+ p(pfsyncs_ipackets, "\t{:received-inet-packets/%ju} "
+ "{N:/packet%s received (IPv4)}\n");
+ p(pfsyncs_ipackets6, "\t{:received-inet6-packets/%ju} "
+ "{N:/packet%s received (IPv6)}\n");
+ pfsync_acts_stats("input-histogram", "received",
&pfsyncstat.pfsyncs_iacts[0]);
- p(pfsyncs_badif, "\t\t%ju packet%s discarded for bad interface\n");
- p(pfsyncs_badttl, "\t\t%ju packet%s discarded for bad ttl\n");
- p(pfsyncs_hdrops, "\t\t%ju packet%s shorter than header\n");
- p(pfsyncs_badver, "\t\t%ju packet%s discarded for bad version\n");
- p(pfsyncs_badauth, "\t\t%ju packet%s discarded for bad HMAC\n");
- p(pfsyncs_badact,"\t\t%ju packet%s discarded for bad action\n");
- p(pfsyncs_badlen, "\t\t%ju packet%s discarded for short packet\n");
- p(pfsyncs_badval, "\t\t%ju state%s discarded for bad values\n");
- p(pfsyncs_stale, "\t\t%ju stale state%s\n");
- p(pfsyncs_badstate, "\t\t%ju failed state lookup/insert%s\n");
- p(pfsyncs_opackets, "\t%ju packet%s sent (IPv4)\n");
- p(pfsyncs_opackets6, "\t%ju packet%s sent (IPv6)\n");
- pfsync_acts_stats("\t %ju %s%s sent\n",
+ p(pfsyncs_badif, "\t\t/{:dropped-bad-interface/%ju} "
+ "{N:/packet%s discarded for bad interface}\n");
+ p(pfsyncs_badttl, "\t\t{:dropped-bad-ttl/%ju} "
+ "{N:/packet%s discarded for bad ttl}\n");
+ p(pfsyncs_hdrops, "\t\t{:dropped-short-header/%ju} "
+ "{N:/packet%s shorter than header}\n");
+ p(pfsyncs_badver, "\t\t{:dropped-bad-version/%ju} "
+ "{N:/packet%s discarded for bad version}\n");
+ p(pfsyncs_badauth, "\t\t{:dropped-bad-auth/%ju} "
+ "{N:/packet%s discarded for bad HMAC}\n");
+ p(pfsyncs_badact,"\t\t{:dropped-bad-action/%ju} "
+ "{N:/packet%s discarded for bad action}\n");
+ p(pfsyncs_badlen, "\t\t{:dropped-short/%ju} "
+ "{N:/packet%s discarded for short packet}\n");
+ p(pfsyncs_badval, "\t\t{:dropped-bad-values/%ju} "
+ "{N:/state%s discarded for bad values}\n");
+ p(pfsyncs_stale, "\t\t{:dropped-stale-state/%ju} "
+ "{N:/stale state%s}\n");
+ p(pfsyncs_badstate, "\t\t{:dropped-failed-lookup/%ju} "
+ "{N:/failed state lookup\\/insert%s}\n");
+ p(pfsyncs_opackets, "\t{:sent-inet-packets/%ju} "
+ "{N:/packet%s sent (IPv4})\n");
+ p(pfsyncs_opackets6, "\t{:send-inet6-packets/%ju} "
+ "{N:/packet%s sent (IPv6})\n");
+ pfsync_acts_stats("output-histogram", "sent",
&pfsyncstat.pfsyncs_oacts[0]);
- p(pfsyncs_onomem, "\t\t%ju failure%s due to mbuf memory error\n");
- p(pfsyncs_oerrors, "\t\t%ju send error%s\n");
+ p(pfsyncs_onomem, "\t\t{:discarded-no-memory/%ju} "
+ "{N:/failure%s due to mbuf memory error}\n");
+ p(pfsyncs_oerrors, "\t\t{:send-errors/%ju} "
+ "{N:/send error%s}\n");
#undef p
+ xo_close_container(name);
}
#endif /* PF */
@@ -162,10 +205,11 @@ pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
* Display a formatted value, or a '-' in the same space.
*/
static void
-show_stat(const char *fmt, int width, u_long value, short showvalue)
+show_stat(const char *fmt, int width, const char *name,
+ u_long value, short showvalue)
{
const char *lsep, *rsep;
- char newfmt[32];
+ char newfmt[64];
lsep = "";
if (strncmp(fmt, "LS", 2) == 0) {
@@ -179,23 +223,42 @@ show_stat(const char *fmt, int width, u_long value, short showvalue)
}
if (showvalue == 0) {
/* Print just dash. */
- sprintf(newfmt, "%s%%%ds%s", lsep, width, rsep);
- printf(newfmt, "-");
+ xo_emit("{P:/%s}{D:/%*s}{P:/%s}", lsep, width, "-", rsep);
return;
}
+ /*
+ * XXX: workaround {P:} modifier can't be empty and doesn't seem to
+ * take args... so we need to conditionally include it in the format.
+ */
+#define maybe_pad(pad) do { \
+ if (strlen(pad)) { \
+ snprintf(newfmt, sizeof(newfmt), "{P:%s}", pad); \
+ xo_emit(newfmt); \
+ } \
+} while (0)
+
if (hflag) {
char buf[5];
/* Format in human readable form. */
humanize_number(buf, sizeof(buf), (int64_t)value, "",
HN_AUTOSCALE, HN_NOSPACE | HN_DECIMAL);
- sprintf(newfmt, "%s%%%ds%s", lsep, width, rsep);
- printf(newfmt, buf);
+ snprintf(newfmt, sizeof(newfmt), "%s%%%ds%s",
+ lsep, width, rsep);
+ xo_emit(newfmt, buf);
+ xo_attr("value", "%lu", value);
+ maybe_pad(lsep);
+ snprintf(newfmt, sizeof(newfmt), "{:%s/%%%ds}", name, width);
+ xo_emit(newfmt, buf);
+ maybe_pad(rsep);
} else {
/* Construct the format string. */
- sprintf(newfmt, "%s%%%d%s%s", lsep, width, fmt, rsep);
- printf(newfmt, value);
+ maybe_pad(lsep);
+ snprintf(newfmt, sizeof(newfmt), "{:%s/%%%d%s}",
+ name, width, fmt);
+ xo_emit(newfmt, value);
+ maybe_pad(rsep);
}
}
@@ -235,34 +298,37 @@ intpr(int interval, void (*pfunc)(char *), int af)
if (aflag && getifmaddrs(&ifmap) != 0)
err(EX_OSERR, "getifmaddrs");
+ xo_open_list("interface");
if (!pfunc) {
if (Wflag)
- printf("%-7.7s", "Name");
+ xo_emit("{T:/%-7.7s}", "Name");
else
- printf("%-5.5s", "Name");
- printf(" %5.5s %-13.13s %-17.17s %8.8s %5.5s %5.5s",
+ xo_emit("{T:/%-5.5s}", "Name");
+ xo_emit(" {T:/%5.5s} {T:/%-13.13s} {T:/%-17.17s} {T:/%8.8s} "
+ "{T:/%5.5s} {T:/%5.5s}",
"Mtu", "Network", "Address", "Ipkts", "Ierrs", "Idrop");
if (bflag)
- printf(" %10.10s","Ibytes");
- printf(" %8.8s %5.5s", "Opkts", "Oerrs");
+ xo_emit(" {T:/%10.10s}","Ibytes");
+ xo_emit(" {T:/%8.8s} {T:/%5.5s}", "Opkts", "Oerrs");
if (bflag)
- printf(" %10.10s","Obytes");
- printf(" %5s", "Coll");
+ xo_emit(" {T:/%10.10s}","Obytes");
+ xo_emit(" {T:/%5s}", "Coll");
if (dflag)
- printf(" %s", "Drop");
- putchar('\n');
+ xo_emit(" {T:/%s}", "Drop");
+ xo_emit("\n");
}
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
bool network = false, link = false;
+ char *name;
if (interface != NULL && strcmp(ifa->ifa_name, interface) != 0)
continue;
+ name = ifa->ifa_name;
+
if (pfunc) {
- char *name;
- name = ifa->ifa_name;
(*pfunc)(name);
/*
@@ -278,19 +344,21 @@ intpr(int interval, void (*pfunc)(char *), int af)
if (af != AF_UNSPEC && ifa->ifa_addr->sa_family != af)
continue;
+ xo_open_instance("interface");
+
if (Wflag)
- printf("%-7.7s", ifa->ifa_name);
+ xo_emit("{tk:name/%-7.7s}", name);
else
- printf("%-5.5s", ifa->ifa_name);
+ xo_emit("{tk:name/%-5.5s}", name);
#define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu)
- show_stat("lu", 6, IFA_MTU(ifa), IFA_MTU(ifa));
+ show_stat("lu", 6, "mtu", IFA_MTU(ifa), IFA_MTU(ifa));
#undef IFA_MTU
switch (ifa->ifa_addr->sa_family) {
case AF_UNSPEC:
- printf("%-13.13s ", "none");
- printf("%-15.15s ", "none");
+ xo_emit("{:network/%-13.13s} ", "none");
+ xo_emit("{:address/%-15.15s} ", "none");
break;
case AF_INET:
{
@@ -298,9 +366,10 @@ intpr(int interval, void (*pfunc)(char *), int af)
sin = (struct sockaddr_in *)ifa->ifa_addr;
mask = (struct sockaddr_in *)ifa->ifa_netmask;
- printf("%-13.13s ", netname(sin->sin_addr.s_addr,
+ xo_emit("{t:network/%-13.13s} ",
+ netname(sin->sin_addr.s_addr,
mask->sin_addr.s_addr));
- printf("%-17.17s ",
+ xo_emit("{t:address/%-17.17s} ",
routename(sin->sin_addr.s_addr));
network = true;
@@ -314,67 +383,82 @@ intpr(int interval, void (*pfunc)(char *), int af)
sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
mask = (struct sockaddr_in6 *)ifa->ifa_netmask;
- printf("%-13.13s ", netname6(sin6, &mask->sin6_addr));
+ xo_emit("{t:network/%-13.13s} ",
+ netname6(sin6, &mask->sin6_addr));
getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len,
addr_buf, sizeof(addr_buf), 0, 0, NI_NUMERICHOST);
- printf("%-17.17s ", addr_buf);
+ xo_emit("{t:address/%-17.17s} ", addr_buf);
network = 1;
break;
- }
+ }
#endif /* INET6 */
case AF_LINK:
{
struct sockaddr_dl *sdl;
char *cp, linknum[10];
- int n, m;
+ int len = 32;
+ char buf[len];
+ int n, z;
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
cp = (char *)LLADDR(sdl);
n = sdl->sdl_alen;
sprintf(linknum, "<Link#%d>", sdl->sdl_index);
- m = printf("%-13.13s ", linknum);
-
- while ((--n >= 0) && (m < 30))
- m += printf("%02x%c", *cp++ & 0xff,
- n > 0 ? ':' : ' ');
- m = 32 - m;
- while (m-- > 0)
- putchar(' ');
-
+ xo_emit("{t:network/%-13.13s} ", linknum);
+ buf[0] = '\0';
+ z = 0;
+ while ((--n >= 0) && (z < len)) {
+ snprintf(buf + z, len - z, "%02x%c",
+ *cp++ & 0xff, n > 0 ? ':' : ' ');
+ z += 3;
+ }
+ if (z > 0)
+ xo_emit("{:address/%*s}", 32 - z, buf);
+ else
+ xo_emit("{P: }");
link = 1;
break;
}
}
#define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s)
- show_stat("lu", 8, IFA_STAT(ipackets), link|network);
- show_stat("lu", 5, IFA_STAT(ierrors), link);
- show_stat("lu", 5, IFA_STAT(iqdrops), link);
+ show_stat("lu", 8, "received-packets", IFA_STAT(ipackets),
+ link|network);
+ show_stat("lu", 5, "received-errors", IFA_STAT(ierrors), link);
+ show_stat("lu", 5, "dropped-packet", IFA_STAT(iqdrops), link);
if (bflag)
- show_stat("lu", 10, IFA_STAT(ibytes), link|network);
- show_stat("lu", 8, IFA_STAT(opackets), link|network);
- show_stat("lu", 5, IFA_STAT(oerrors), link);
+ show_stat("lu", 10, "received-bytes", IFA_STAT(ibytes),
+ link|network);
+ show_stat("lu", 8, "sent-packets", IFA_STAT(opackets),
+ link|network);
+ show_stat("lu", 5, "send-errors", IFA_STAT(oerrors), link);
if (bflag)
- show_stat("lu", 10, IFA_STAT(obytes), link|network);
- show_stat("NRSlu", 5, IFA_STAT(collisions), link);
+ show_stat("lu", 10, "sent-bytes", IFA_STAT(obytes),
+ link|network);
+ show_stat("NRSlu", 5, "collisions", IFA_STAT(collisions), link);
if (dflag)
- show_stat("LSlu", 5, IFA_STAT(oqdrops), link);
- putchar('\n');
+ show_stat("LSlu", 5, "dropped-packets",
+ IFA_STAT(oqdrops), link);
+ xo_emit("\n");
- if (!aflag)
+ if (!aflag) {
+ xo_close_instance("interface");
continue;
+ }
/*
* Print family's multicast addresses.
*/
+ xo_open_list("multicast-address");
for (ifma = next_ifma(ifmap, ifa->ifa_name,
- ifa->ifa_addr->sa_family);
- ifma != NULL;
- ifma = next_ifma(ifma, ifa->ifa_name,
- ifa->ifa_addr->sa_family)) {
+ ifa->ifa_addr->sa_family);
+ ifma != NULL;
+ ifma = next_ifma(ifma, ifa->ifa_name,
+ ifa->ifa_addr->sa_family)) {
const char *fmt = NULL;
+ xo_open_instance("multicast-address");
switch (ifma->ifma_addr->sa_family) {
case AF_INET:
{
@@ -391,7 +475,7 @@ intpr(int interval, void (*pfunc)(char *), int af)
getnameinfo(ifma->ifma_addr,
ifma->ifma_addr->sa_len, addr_buf,
sizeof(addr_buf), 0, 0, NI_NUMERICHOST);
- printf("%*s %s\n",
+ xo_emit("{P:/%*s }{t:address/%-19.19s}",
Wflag ? 27 : 25, "", addr_buf);
break;
#endif /* INET6 */
@@ -412,21 +496,24 @@ intpr(int interval, void (*pfunc)(char *), int af)
}
if (fmt) {
- printf("%*s %-17.17s",
+ xo_emit("{P:/%*s }{t:address/%-17.17s/}",
Wflag ? 27 : 25, "", fmt);
if (ifma->ifma_addr->sa_family == AF_LINK) {
- printf(" %8ju",
- (uintmax_t )IFA_STAT(imcasts));
- printf("%*s", bflag ? 17 : 6, "");
- printf(" %8ju",
- (uintmax_t )IFA_STAT(omcasts));
- }
- putchar('\n');
+ xo_emit(" {:received-packets/%8lu}",
+ IFA_STAT(imcasts));
+ xo_emit("{P:/%*s}", bflag? 17 : 6, "");
+ xo_emit(" {:sent-packets/%8lu}",
+ IFA_STAT(omcasts));
+ }
+ xo_emit("\n");
}
-
+ xo_close_instance("multicast-address");
ifma = ifma->ifma_next;
}
+ xo_close_list("multicast-address");
+ xo_close_instance("interface");
}
+ xo_close_list("interface");
freeifaddrs(ifap);
if (aflag)
@@ -455,7 +542,7 @@ fill_iftot(struct iftot *st)
bool found = false;
if (getifaddrs(&ifap) != 0)
- err(EX_OSERR, "getifaddrs");
+ xo_err(EX_OSERR, "getifaddrs");
bzero(st, sizeof(*st));
@@ -481,7 +568,7 @@ fill_iftot(struct iftot *st)
}
if (interface && found == false)
- err(EX_DATAERR, "interface %s not found", interface);
+ xo_err(EX_DATAERR, "interface %s not found", interface);
freeifaddrs(ifap);
}
@@ -520,23 +607,26 @@ sidewaysintpr(int interval)
interval_it.it_interval.tv_usec = 0;
interval_it.it_value = interval_it.it_interval;
setitimer(ITIMER_REAL, &interval_it, NULL);
+ xo_open_list("interface-statistics");
banner:
- printf("%17s %14s %16s", "input",
+ xo_emit("{T:/%17s} {T:/%14s} {T:/%16s}\n", "input",
interface != NULL ? interface : "(Total)", "output");
- putchar('\n');
- printf("%10s %5s %5s %10s %10s %5s %10s %5s",
+ xo_emit("{T:/%10s} {T:/%5s} {T:/%5s} {T:/%10s} {T:/%10s} {T:/%5s} "
+ "{T:/%10s} {T:/%5s}",
"packets", "errs", "idrops", "bytes", "packets", "errs", "bytes",
"colls");
if (dflag)
- printf(" %5.5s", "drops");
- putchar('\n');
- fflush(stdout);
+ xo_emit(" {T:/%5.5s}", "drops");
+ xo_emit("\n");
+ xo_flush();
line = 0;
loop:
- if ((noutputs != 0) && (--noutputs == 0))
- exit(0);
+ if ((noutputs != 0) && (--noutputs == 0)) {
+ xo_close_list("interface-statistics");
+ return;
+ }
oldmask = sigblock(sigmask(SIGALRM));
while (!signalled)
sigpause(0);
@@ -546,18 +636,29 @@ loop:
fill_iftot(new);
- show_stat("lu", 10, new->ift_ip - old->ift_ip, 1);
- show_stat("lu", 5, new->ift_ie - old->ift_ie, 1);
- show_stat("lu", 5, new->ift_id - old->ift_id, 1);
- show_stat("lu", 10, new->ift_ib - old->ift_ib, 1);
- show_stat("lu", 10, new->ift_op - old->ift_op, 1);
- show_stat("lu", 5, new->ift_oe - old->ift_oe, 1);
- show_stat("lu", 10, new->ift_ob - old->ift_ob, 1);
- show_stat("NRSlu", 5, new->ift_co - old->ift_co, 1);
+ xo_open_instance("stats");
+ show_stat("lu", 10, "received-packets",
+ new->ift_ip - old->ift_ip, 1);
+ show_stat("lu", 5, "received-errors",
+ new->ift_ie - old->ift_ie, 1);
+ show_stat("lu", 5, "dropped-packets",
+ new->ift_id - old->ift_id, 1);
+ show_stat("lu", 10, "received-bytes",
+ new->ift_ib - old->ift_ib, 1);
+ show_stat("lu", 10, "sent-packets",
+ new->ift_op - old->ift_op, 1);
+ show_stat("lu", 5, "send-errors",
+ new->ift_oe - old->ift_oe, 1);
+ show_stat("lu", 10, "sent-bytes",
+ new->ift_ob - old->ift_ob, 1);
+ show_stat("NRSlu", 5, "collisions",
+ new->ift_co - old->ift_co, 1);
if (dflag)
- show_stat("LSlu", 5, new->ift_od - old->ift_od, 1);
- putchar('\n');
- fflush(stdout);
+ show_stat("LSlu", 5, "dropped-packets",
+ new->ift_od - old->ift_od, 1);
+ xo_close_instance("stats");
+ xo_emit("\n");
+ xo_flush();
if (new == &ift[0]) {
new = &ift[1];
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index b4bd312..c966bf4 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -78,12 +78,14 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "netstat.h"
char *inetname(struct in_addr *);
-void inetprint(struct in_addr *, int, const char *, int);
+void inetprint(const char *, struct in_addr *, int, const char *, int);
#ifdef INET6
static int udp_done, tcp_done, sdp_done;
#endif /* INET6 */
@@ -114,15 +116,15 @@ pcblist_sysctl(int proto, const char *name, char **bufp, int istcp __unused)
len = 0;
if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: %s", mibvar);
+ xo_warn("sysctl: %s", mibvar);
return (0);
}
if ((buf = malloc(len)) == 0) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return (0);
}
if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
- warn("sysctl: %s", mibvar);
+ xo_warn("sysctl: %s", mibvar);
free(buf);
return (0);
}
@@ -205,14 +207,14 @@ pcblist_kvm(u_long off, char **bufp, int istcp)
(pcbinfo.ipi_count + pcbinfo.ipi_count / 8) *
sizeof(struct xinpcb);
if ((buf = malloc(len)) == 0) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return (0);
}
p = buf;
#define COPYOUT(obj, size) do { \
if (len < (size)) { \
- warnx("buffer size exceeded"); \
+ xo_warnx("buffer size exceeded"); \
goto fail; \
} \
bcopy((obj), p, (size)); \
@@ -349,8 +351,8 @@ protopr(u_long off, const char *name, int af1, int proto)
oxig = xig = (struct xinpgen *)buf;
for (xig = (struct xinpgen *)((char *)xig + xig->xig_len);
- xig->xig_len > sizeof(struct xinpgen);
- xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
+ xig->xig_len > sizeof(struct xinpgen);
+ xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
if (istcp) {
timer = &((struct xtcpcb *)xig)->xt_timer;
tp = &((struct xtcpcb *)xig)->xt_tp;
@@ -403,186 +405,218 @@ protopr(u_long off, const char *name, int af1, int proto)
if (first) {
if (!Lflag) {
- printf("Active Internet connections");
+ xo_emit("Active Internet connections");
if (aflag)
- printf(" (including servers)");
+ xo_emit(" (including servers)");
} else
- printf(
+ xo_emit(
"Current listen queue sizes (qlen/incqlen/maxqlen)");
- putchar('\n');
+ xo_emit("\n");
if (Aflag)
- printf("%-*s ", 2 * (int)sizeof(void *), "Tcpcb");
+ xo_emit("{T:/%-*s} ", 2 * (int)sizeof(void *),
+ "Tcpcb");
if (Lflag)
- printf((Aflag && !Wflag) ?
- "%-5.5s %-14.14s %-18.18s" :
- "%-5.5s %-14.14s %-22.22s",
+ xo_emit((Aflag && !Wflag) ?
+ "{T:/%-5.5s} {T:/%-14.14s} {T:/%-18.18s}" :
+ "{T:/%-5.5s} {T:/%-14.14s} {T:/%-22.22s}",
"Proto", "Listen", "Local Address");
else if (Tflag)
- printf((Aflag && !Wflag) ?
- "%-5.5s %-6.6s %-6.6s %-6.6s %-18.18s %s" :
- "%-5.5s %-6.6s %-6.6s %-6.6s %-22.22s %s",
+ xo_emit((Aflag && !Wflag) ?
+ "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
+ "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}",
"Proto", "Rexmit", "OOORcv", "0-win",
"Local Address", "Foreign Address");
else {
- printf((Aflag && !Wflag) ?
- "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" :
- "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s",
- "Proto", "Recv-Q", "Send-Q",
- "Local Address", "Foreign Address");
+ xo_emit((Aflag && !Wflag) ?
+ "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
+ "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}",
+ "Proto", "Recv-Q", "Send-Q",
+ "Local Address", "Foreign Address");
if (!xflag && !Rflag)
- printf(" (state)");
+ xo_emit(" (state)");
}
if (xflag) {
- printf(" %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s",
- "R-MBUF", "S-MBUF", "R-CLUS",
- "S-CLUS", "R-HIWA", "S-HIWA",
- "R-LOWA", "S-LOWA", "R-BCNT",
- "S-BCNT", "R-BMAX", "S-BMAX");
- printf(" %7.7s %7.7s %7.7s %7.7s %7.7s %7.7s",
- "rexmt", "persist", "keep",
- "2msl", "delack", "rcvtime");
+ xo_emit(" {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} "
+ "{T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} "
+ "{T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} "
+ "{T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s}",
+ "R-MBUF", "S-MBUF", "R-CLUS", "S-CLUS",
+ "R-HIWA", "S-HIWA", "R-LOWA", "S-LOWA",
+ "R-BCNT", "S-BCNT", "R-BMAX", "S-BMAX");
+ xo_emit(" {T:/%7.7s} {T:/%7.7s} {T:/%7.7s} "
+ "{T:/%7.7s} {T:/%7.7s} {T:/%7.7s}",
+ "rexmt", "persist", "keep", "2msl",
+ "delack", "rcvtime");
} else if (Rflag) {
- printf (" %8.8s %5.5s",
+ xo_emit(" {T:/%8.8s} {T:/%5.5s}",
"flowid", "ftype");
}
- putchar('\n');
+ xo_emit("\n");
first = 0;
}
if (Lflag && so->so_qlimit == 0)
continue;
+ xo_open_instance("socket");
if (Aflag) {
if (istcp)
- printf("%*lx ", 2 * (int)sizeof(void *), (u_long)inp->inp_ppcb);
+ xo_emit("{q:address/%*lx} ",
+ 2 * (int)sizeof(void *),
+ (u_long)inp->inp_ppcb);
else
- printf("%*lx ", 2 * (int)sizeof(void *), (u_long)so->so_pcb);
+ xo_emit("{q:adddress/%*lx} ",
+ 2 * (int)sizeof(void *),
+ (u_long)so->so_pcb);
}
#ifdef INET6
if ((inp->inp_vflag & INP_IPV6) != 0)
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
- "46" : "6 ";
+ "46" : "6";
else
#endif
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
- "4 " : " ";
+ "4" : "";
if (istcp && (tp->t_flags & TF_TOE) != 0)
- printf("%-3.3s%-2.2s ", "toe", vchar);
+ xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", "toe", vchar);
else
- printf("%-3.3s%-2.2s ", name, vchar);
+ xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", name, vchar);
if (Lflag) {
char buf1[15];
snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
so->so_incqlen, so->so_qlimit);
- printf("%-14.14s ", buf1);
+ xo_emit("{:listen-queue-sizes/%-14.14s} ", buf1);
} else if (Tflag) {
if (istcp)
- printf("%6u %6u %6u ", tp->t_sndrexmitpack,
- tp->t_rcvoopack, tp->t_sndzerowin);
+ xo_emit("{:sent-retransmit-packets/%6u} "
+ "{:received-out-of-order-packets/%6u} "
+ "{:sent-zero-window/%6u} ",
+ tp->t_sndrexmitpack, tp->t_rcvoopack,
+ tp->t_sndzerowin);
} else {
- printf("%6u %6u ",
+ xo_emit("{:receive-bytes-waiting/%6u} "
+ "{:send-bytes-waiting/%6u} ",
so->so_rcv.sb_cc, so->so_snd.sb_cc);
}
if (numeric_port) {
if (inp->inp_vflag & INP_IPV4) {
- inetprint(&inp->inp_laddr, (int)inp->inp_lport,
- name, 1);
+ inetprint("local", &inp->inp_laddr,
+ (int)inp->inp_lport, name, 1);
if (!Lflag)
- inetprint(&inp->inp_faddr,
+ inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name, 1);
}
#ifdef INET6
else if (inp->inp_vflag & INP_IPV6) {
- inet6print(&inp->in6p_laddr,
+ inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
if (!Lflag)
- inet6print(&inp->in6p_faddr,
+ inet6print("remote", &inp->in6p_faddr,
(int)inp->inp_fport, name, 1);
} /* else nothing printed now */
#endif /* INET6 */
} else if (inp->inp_flags & INP_ANONPORT) {
if (inp->inp_vflag & INP_IPV4) {
- inetprint(&inp->inp_laddr, (int)inp->inp_lport,
- name, 1);
+ inetprint("local", &inp->inp_laddr,
+ (int)inp->inp_lport, name, 1);
if (!Lflag)
- inetprint(&inp->inp_faddr,
+ inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name, 0);
}
#ifdef INET6
else if (inp->inp_vflag & INP_IPV6) {
- inet6print(&inp->in6p_laddr,
+ inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
if (!Lflag)
- inet6print(&inp->in6p_faddr,
+ inet6print("remote", &inp->in6p_faddr,
(int)inp->inp_fport, name, 0);
} /* else nothing printed now */
#endif /* INET6 */
} else {
if (inp->inp_vflag & INP_IPV4) {
- inetprint(&inp->inp_laddr, (int)inp->inp_lport,
- name, 0);
+ inetprint("local", &inp->inp_laddr,
+ (int)inp->inp_lport, name, 0);
if (!Lflag)
- inetprint(&inp->inp_faddr,
+ inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name,
inp->inp_lport != inp->inp_fport);
}
#ifdef INET6
else if (inp->inp_vflag & INP_IPV6) {
- inet6print(&inp->in6p_laddr,
+ inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 0);
if (!Lflag)
- inet6print(&inp->in6p_faddr,
+ inet6print("remote", &inp->in6p_faddr,
(int)inp->inp_fport, name,
inp->inp_lport != inp->inp_fport);
} /* else nothing printed now */
#endif /* INET6 */
}
if (xflag) {
- printf("%6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u",
- so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt,
- so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt,
- so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat,
- so->so_rcv.sb_lowat, so->so_snd.sb_lowat,
- so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt,
- so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax);
+ xo_emit("{:receive-mbufs/%6u} {:send-mbufs/%6u} "
+ "{:receive-clusters/%6u} {:send-clusters/%6u} "
+ "{:receive-high-water/%6u} {:send-high-water/%6u} "
+ "{:receive-low-water/%6u} {:send-low-water/%6u} "
+ "{:receive-mbuf-bytes/%6u} {:send-mbuf-bytes/%6u} "
+ "{:receive-mbuf-bytes-max/%6u} "
+ "{:send-mbuf-bytes-max/%6u}",
+ so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt,
+ so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt,
+ so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat,
+ so->so_rcv.sb_lowat, so->so_snd.sb_lowat,
+ so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt,
+ so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax);
if (timer != NULL)
- printf(" %4d.%02d %4d.%02d %4d.%02d %4d.%02d %4d.%02d %4d.%02d",
- timer->tt_rexmt / 1000, (timer->tt_rexmt % 1000) / 10,
- timer->tt_persist / 1000, (timer->tt_persist % 1000) / 10,
- timer->tt_keep / 1000, (timer->tt_keep % 1000) / 10,
- timer->tt_2msl / 1000, (timer->tt_2msl % 1000) / 10,
- timer->tt_delack / 1000, (timer->tt_delack % 1000) / 10,
- timer->t_rcvtime / 1000, (timer->t_rcvtime % 1000) / 10);
+ xo_emit(" {:retransmit-timer/%4d.%02d} "
+ "{:persist-timer/%4d.%02d} "
+ "{:keepalive-timer/%4d.%02d} "
+ "{:msl2-timer/%4d.%02d} "
+ "{:delay-ack-timer/%4d.%02d} "
+ "{:inactivity-timer/%4d.%02d}",
+ timer->tt_rexmt / 1000,
+ (timer->tt_rexmt % 1000) / 10,
+ timer->tt_persist / 1000,
+ (timer->tt_persist % 1000) / 10,
+ timer->tt_keep / 1000,
+ (timer->tt_keep % 1000) / 10,
+ timer->tt_2msl / 1000,
+ (timer->tt_2msl % 1000) / 10,
+ timer->tt_delack / 1000,
+ (timer->tt_delack % 1000) / 10,
+ timer->t_rcvtime / 1000,
+ (timer->t_rcvtime % 1000) / 10);
}
if (istcp && !Lflag && !xflag && !Tflag && !Rflag) {
if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES)
- printf("%d", tp->t_state);
+ xo_emit("{:tcp-state/%d}", tp->t_state);
else {
- printf("%s", tcpstates[tp->t_state]);
+ xo_emit("{:tcp-state/%s}",
+ tcpstates[tp->t_state]);
#if defined(TF_NEEDSYN) && defined(TF_NEEDFIN)
/* Show T/TCP `hidden state' */
if (tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN))
- putchar('*');
+ xo_emit("{:need-syn-or-fin/*}");
#endif /* defined(TF_NEEDSYN) && defined(TF_NEEDFIN) */
}
}
if (Rflag) {
- printf(" %08x %5d",
+ /* XXX: is this right Alfred */
+ xo_emit(" {:flow-id/%08x} {:flow-type/%5d}",
inp->inp_flowid,
inp->inp_flowtype);
}
- putchar('\n');
+ xo_emit("\n");
+ xo_close_instance("socket");
}
if (xig != oxig && xig->xig_gen != oxig->xig_gen) {
if (oxig->xig_count > xig->xig_count) {
- printf("Some %s sockets may have been deleted.\n",
- name);
+ xo_emit("Some {d:lost/%s} sockets may have been "
+ "deleted.\n", name);
} else if (oxig->xig_count < xig->xig_count) {
- printf("Some %s sockets may have been created.\n",
- name);
+ xo_emit("Some {d:created/%s} sockets may have been "
+ "created.\n", name);
} else {
- printf(
- "Some %s sockets may have been created or deleted.\n",
- name);
+ xo_emit("Some {d:changed/%s} sockets may have been "
+ "created or deleted.\n", name);
}
}
free(buf);
@@ -609,146 +643,216 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
memset(&zerostat, 0, len);
if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.tcp.stats");
+ xo_warn("sysctl: net.inet.tcp.stats");
return;
}
} else
kread_counters(off, &tcpstat, len);
- printf ("%s:\n", name);
+ xo_open_container("tcp");
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (tcpstat.f || sflag <= 1) \
- printf(m, (uintmax_t )tcpstat.f, plural(tcpstat.f))
-
+ xo_emit(m, (uintmax_t )tcpstat.f, plural(tcpstat.f))
#define p1a(f, m) if (tcpstat.f || sflag <= 1) \
- printf(m, (uintmax_t )tcpstat.f)
-
+ xo_emit(m, (uintmax_t )tcpstat.f)
#define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
- printf(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \
+ xo_emit(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \
(uintmax_t )tcpstat.f2, plural(tcpstat.f2))
-
#define p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
- printf(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \
+ xo_emit(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \
(uintmax_t )tcpstat.f2)
-
#define p3(f, m) if (tcpstat.f || sflag <= 1) \
- printf(m, (uintmax_t )tcpstat.f, pluralies(tcpstat.f))
-
- p(tcps_sndtotal, "\t%ju packet%s sent\n");
- p2(tcps_sndpack,tcps_sndbyte, "\t\t%ju data packet%s (%ju byte%s)\n");
- p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
- "\t\t%ju data packet%s (%ju byte%s) retransmitted\n");
- p(tcps_sndrexmitbad,
- "\t\t%ju data packet%s unnecessarily retransmitted\n");
- p(tcps_mturesent, "\t\t%ju resend%s initiated by MTU discovery\n");
- p2a(tcps_sndacks, tcps_delack,
- "\t\t%ju ack-only packet%s (%ju delayed)\n");
- p(tcps_sndurg, "\t\t%ju URG only packet%s\n");
- p(tcps_sndprobe, "\t\t%ju window probe packet%s\n");
- p(tcps_sndwinup, "\t\t%ju window update packet%s\n");
- p(tcps_sndctrl, "\t\t%ju control packet%s\n");
- p(tcps_rcvtotal, "\t%ju packet%s received\n");
- p2(tcps_rcvackpack, tcps_rcvackbyte,
- "\t\t%ju ack%s (for %ju byte%s)\n");
- p(tcps_rcvdupack, "\t\t%ju duplicate ack%s\n");
- p(tcps_rcvacktoomuch, "\t\t%ju ack%s for unsent data\n");
- p2(tcps_rcvpack, tcps_rcvbyte,
- "\t\t%ju packet%s (%ju byte%s) received in-sequence\n");
- p2(tcps_rcvduppack, tcps_rcvdupbyte,
- "\t\t%ju completely duplicate packet%s (%ju byte%s)\n");
- p(tcps_pawsdrop, "\t\t%ju old duplicate packet%s\n");
- p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
- "\t\t%ju packet%s with some dup. data (%ju byte%s duped)\n");
- p2(tcps_rcvoopack, tcps_rcvoobyte,
- "\t\t%ju out-of-order packet%s (%ju byte%s)\n");
- p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
- "\t\t%ju packet%s (%ju byte%s) of data after window\n");
- p(tcps_rcvwinprobe, "\t\t%ju window probe%s\n");
- p(tcps_rcvwinupd, "\t\t%ju window update packet%s\n");
- p(tcps_rcvafterclose, "\t\t%ju packet%s received after close\n");
- p(tcps_rcvbadsum, "\t\t%ju discarded for bad checksum%s\n");
- p(tcps_rcvbadoff, "\t\t%ju discarded for bad header offset field%s\n");
- p1a(tcps_rcvshort, "\t\t%ju discarded because packet too short\n");
- p1a(tcps_rcvreassfull,
- "\t\t%ju discarded due to no space in reassembly queue\n");
- p(tcps_connattempt, "\t%ju connection request%s\n");
- p(tcps_accepts, "\t%ju connection accept%s\n");
- p(tcps_badsyn, "\t%ju bad connection attempt%s\n");
- p(tcps_listendrop, "\t%ju listen queue overflow%s\n");
- p(tcps_badrst, "\t%ju ignored RSTs in the window%s\n");
- p(tcps_connects, "\t%ju connection%s established (including accepts)\n");
- p2(tcps_closed, tcps_drops,
- "\t%ju connection%s closed (including %ju drop%s)\n");
- p(tcps_cachedrtt, "\t\t%ju connection%s updated cached RTT on close\n");
- p(tcps_cachedrttvar,
- "\t\t%ju connection%s updated cached RTT variance on close\n");
- p(tcps_cachedssthresh,
- "\t\t%ju connection%s updated cached ssthresh on close\n");
- p(tcps_conndrops, "\t%ju embryonic connection%s dropped\n");
- p2(tcps_rttupdated, tcps_segstimed,
- "\t%ju segment%s updated rtt (of %ju attempt%s)\n");
- p(tcps_rexmttimeo, "\t%ju retransmit timeout%s\n");
- p(tcps_timeoutdrop, "\t\t%ju connection%s dropped by rexmit timeout\n");
- p(tcps_persisttimeo, "\t%ju persist timeout%s\n");
- p(tcps_persistdrop, "\t\t%ju connection%s dropped by persist timeout\n");
- p(tcps_finwait2_drops,
- "\t%ju Connection%s (fin_wait_2) dropped because of timeout\n");
- p(tcps_keeptimeo, "\t%ju keepalive timeout%s\n");
- p(tcps_keepprobe, "\t\t%ju keepalive probe%s sent\n");
- p(tcps_keepdrops, "\t\t%ju connection%s dropped by keepalive\n");
- p(tcps_predack, "\t%ju correct ACK header prediction%s\n");
- p(tcps_preddat, "\t%ju correct data packet header prediction%s\n");
-
- p3(tcps_sc_added, "\t%ju syncache entr%s added\n");
- p1a(tcps_sc_retransmitted, "\t\t%ju retransmitted\n");
- p1a(tcps_sc_dupsyn, "\t\t%ju dupsyn\n");
- p1a(tcps_sc_dropped, "\t\t%ju dropped\n");
- p1a(tcps_sc_completed, "\t\t%ju completed\n");
- p1a(tcps_sc_bucketoverflow, "\t\t%ju bucket overflow\n");
- p1a(tcps_sc_cacheoverflow, "\t\t%ju cache overflow\n");
- p1a(tcps_sc_reset, "\t\t%ju reset\n");
- p1a(tcps_sc_stale, "\t\t%ju stale\n");
- p1a(tcps_sc_aborted, "\t\t%ju aborted\n");
- p1a(tcps_sc_badack, "\t\t%ju badack\n");
- p1a(tcps_sc_unreach, "\t\t%ju unreach\n");
- p(tcps_sc_zonefail, "\t\t%ju zone failure%s\n");
- p(tcps_sc_sendcookie, "\t%ju cookie%s sent\n");
- p(tcps_sc_recvcookie, "\t%ju cookie%s received\n");
-
- p3(tcps_hc_added, "\t%ju hostcache entr%s added\n");
- p1a(tcps_hc_bucketoverflow, "\t\t%ju bucket overflow\n");
-
- p(tcps_sack_recovery_episode, "\t%ju SACK recovery episode%s\n");
- p(tcps_sack_rexmits,
- "\t%ju segment rexmit%s in SACK recovery episodes\n");
- p(tcps_sack_rexmit_bytes,
- "\t%ju byte rexmit%s in SACK recovery episodes\n");
- p(tcps_sack_rcv_blocks,
- "\t%ju SACK option%s (SACK blocks) received\n");
- p(tcps_sack_send_blocks, "\t%ju SACK option%s (SACK blocks) sent\n");
- p1a(tcps_sack_sboverflow, "\t%ju SACK scoreboard overflow\n");
-
- p(tcps_ecn_ce, "\t%ju packet%s with ECN CE bit set\n");
- p(tcps_ecn_ect0, "\t%ju packet%s with ECN ECT(0) bit set\n");
- p(tcps_ecn_ect1, "\t%ju packet%s with ECN ECT(1) bit set\n");
- p(tcps_ecn_shs, "\t%ju successful ECN handshake%s\n");
- p(tcps_ecn_rcwnd, "\t%ju time%s ECN reduced the congestion window\n");
-
- p(tcps_sig_rcvgoodsig,
- "\t%ju packet%s with valid tcp-md5 signature received\n");
- p(tcps_sig_rcvbadsig,
- "\t%ju packet%s with invalid tcp-md5 signature received\n");
- p(tcps_sig_err_buildsig,
- "\t%ju packet%s with tcp-md5 signature mismatch\n");
- p(tcps_sig_err_sigopt,
- "\t%ju packet%s with unexpected tcp-md5 signature received\n");
- p(tcps_sig_err_nosigopt,
- "\t%ju packet%s without expected tcp-md5 signature received\n");
-#undef p
-#undef p1a
-#undef p2
-#undef p2a
-#undef p3
+ xo_emit(m, (uintmax_t )tcpstat.f, pluralies(tcpstat.f))
+
+ p(tcps_sndtotal, "\t{:sent-packets/%ju} {N:/packet%s sent}\n");
+ p2(tcps_sndpack,tcps_sndbyte, "\t\t{:sent-data-packets/%ju} "
+ "{N:/data packet%s} ({:sent-data-bytes/%ju} {N:/byte%s})\n");
+ p2(tcps_sndrexmitpack, tcps_sndrexmitbyte, "\t\t"
+ "{:sent-retransmitted-packets/%ju} {N:/data packet%s} "
+ "({:sent-retransmitted-bytes/%ju} {N:/byte%s}) "
+ "{N:retransmitted}\n");
+ p(tcps_sndrexmitbad, "\t\t"
+ "{:sent-unnecessary-retransmitted-packets/%ju} "
+ "{N:/data packet%s unnecessarily retransmitted}\n");
+ p(tcps_mturesent, "\t\t{:sent-resends-by-mtu-discovery/%ju} "
+ "{N:/resend%s initiated by MTU discovery}\n");
+ p2a(tcps_sndacks, tcps_delack, "\t\t{:sent-ack-only-packets/%ju} "
+ "{N:/ack-only packet%s/} ({:sent-packets-delayed/%ju} "
+ "{N:delayed})\n");
+ p(tcps_sndurg, "\t\t{:sent-urg-only-packets/%ju} "
+ "{N:/URG only packet%s}\n");
+ p(tcps_sndprobe, "\t\t{:sent-window-probe-packets/%ju} "
+ "{N:/window probe packet%s}\n");
+ p(tcps_sndwinup, "\t\t{:sent-window-update-packets/%ju} "
+ "{N:/window update packet%s}\n");
+ p(tcps_sndctrl, "\t\t{:sent-control-packets/%ju} "
+ "{N:/control packet%s}\n");
+ p(tcps_rcvtotal, "\t{:received-packets/%ju} "
+ "{N:/packet%s received}\n");
+ p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t"
+ "{:received-ack-packets/%ju} {N:/ack%s} "
+ "{N:(for} {:received-ack-bytes/%ju} {N:/byte%s})\n");
+ p(tcps_rcvdupack, "\t\t{:received-duplicate-acks/%ju} "
+ "{N:/duplicate ack%s}\n");
+ p(tcps_rcvacktoomuch, "\t\t{:received-acks-for-unsent-data/%ju} "
+ "{N:/ack%s for unsent data}\n");
+ p2(tcps_rcvpack, tcps_rcvbyte, "\t\t"
+ "{:received-in-sequence-packets/%ju} {N:/packet%s} "
+ "({:received-in-sequence-bytes/%ju} {N:/byte%s}) "
+ "{N:received in-sequence}\n");
+ p2(tcps_rcvduppack, tcps_rcvdupbyte, "\t\t"
+ "{:received-completely-duplicate-packets/%ju} "
+ "{N:/completely duplicate packet%s} "
+ "({:received-completely-duplicate-bytes/%ju} {N:/byte%s})\n");
+ p(tcps_pawsdrop, "\t\t{:received-old-duplicate-packets/%ju} "
+ "{N:/old duplicate packet%s}\n");
+ p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte, "\t\t"
+ "{:received-some-duplicate-packets/%ju} "
+ "{N:/packet%s with some dup. data} "
+ "({:received-some-duplicate-bytes/%ju} {N:/byte%s duped/})\n");
+ p2(tcps_rcvoopack, tcps_rcvoobyte, "\t\t{:received-out-of-order/%ju} "
+ "{N:/out-of-order packet%s} "
+ "({:received-out-of-order-bytes/%ju} {N:/byte%s})\n");
+ p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin, "\t\t"
+ "{:received-after-window-packets/%ju} {N:/packet%s} "
+ "({:received-after-window-bytes/%ju} {N:/byte%s}) "
+ "{N:of data after window}\n");
+ p(tcps_rcvwinprobe, "\t\t{:received-window-probes/%ju} "
+ "{N:/window probe%s}\n");
+ p(tcps_rcvwinupd, "\t\t{:receive-window-update-packets/%ju} "
+ "{N:/window update packet%s}\n");
+ p(tcps_rcvafterclose, "\t\t{:received-after-close-packets/%ju} "
+ "{N:/packet%s received after close}\n");
+ p(tcps_rcvbadsum, "\t\t{:discard-bad-checksum/%ju} "
+ "{N:/discarded for bad checksum%s}\n");
+ p(tcps_rcvbadoff, "\t\t{:discard-bad-header-offset/%ju} "
+ "{N:/discarded for bad header offset field%s}\n");
+ p1a(tcps_rcvshort, "\t\t{:discard-too-short/%ju} "
+ "{N:discarded because packet too short}\n");
+ p1a(tcps_rcvmemdrop, "\t\t{:discard-memory-problems/%ju} "
+ "{N:discarded due to memory problems}\n");
+ p(tcps_connattempt, "\t{:connection-requests/%ju} "
+ "{N:/connection request%s}\n");
+ p(tcps_accepts, "\t{:connections-accepts/%ju} "
+ "{N:/connection accept%s}\n");
+ p(tcps_badsyn, "\t{:bad-connection-attempts/%ju} "
+ "{N:/bad connection attempt%s}\n");
+ p(tcps_listendrop, "\t{:listen-queue-overflows/%ju} "
+ "{N:/listen queue overflow%s}\n");
+ p(tcps_badrst, "\t{:ignored-in-window-resets/%ju} "
+ "{N:/ignored RSTs in the window%s}\n");
+ p(tcps_connects, "\t{:connections-established/%ju} "
+ "{N:/connection%s established (including accepts)}\n");
+ p2(tcps_closed, tcps_drops, "\t{:connections-closed/%ju} "
+ "{N:/connection%s closed (including} "
+ "{:connection-drops/%ju} {N:/drop%s})\n");
+ p(tcps_cachedrtt, "\t\t{:connections-updated-rtt-on-close/%ju} "
+ "{N:/connection%s updated cached RTT on close}\n");
+ p(tcps_cachedrttvar, "\t\t"
+ "{:connections-updated-variance-on-close/%ju} "
+ "{N:/connection%s updated cached RTT variance on close}\n");
+ p(tcps_cachedssthresh, "\t\t"
+ "{:connections-updated-ssthresh-on-close/%ju} "
+ "{N:/connection%s updated cached ssthresh on close}\n");
+ p(tcps_conndrops, "\t{:embryonic-connections-dropped/%ju} "
+ "{N:/embryonic connection%s dropped}\n");
+ p2(tcps_rttupdated, tcps_segstimed, "\t{:segments-updated-rtt/%ju} "
+ "{N:/segment%s updated rtt (of} "
+ "{:segment-update-attempts/%ju} {N:/attempt%s})\n");
+ p(tcps_rexmttimeo, "\t{:retransmit-timeouts/%ju} "
+ "{N:/retransmit timeout%s}\n");
+ p(tcps_timeoutdrop, "\t\t"
+ "{:connections-dropped-by-retransmit-timeout/%ju} "
+ "{N:/connection%s dropped by rexmit timeout}\n");
+ p(tcps_persisttimeo, "\t{:persist-timeout/%ju} "
+ "{N:/persist timeout%s}\n");
+ p(tcps_persistdrop, "\t\t"
+ "{:connections-dropped-by-persist-timeout/%ju} "
+ "{N:/connection%s dropped by persist timeout}\n");
+ p(tcps_finwait2_drops, "\t"
+ "{:connections-dropped-by-finwait2-timeout/%ju} "
+ "{N:/Connection%s (fin_wait_2) dropped because of timeout}\n");
+ p(tcps_keeptimeo, "\t{:keepalive-timeout/%ju} "
+ "{N:/keepalive timeout%s}\n");
+ p(tcps_keepprobe, "\t\t{:keepalive-probes/%ju} "
+ "{N:/keepalive probe%s sent}\n");
+ p(tcps_keepdrops, "\t\t{:connections-dropped-by-keepalives/%ju} "
+ "{N:/connection%s dropped by keepalive}\n");
+ p(tcps_predack, "\t{:ack-header-predictions/%ju} "
+ "{N:/correct ACK header prediction%s}\n");
+ p(tcps_preddat, "\t{:data-packet-header-predictions/%ju} "
+ "{N:/correct data packet header prediction%s}\n");
+
+ xo_open_container("syncache");
+
+ p3(tcps_sc_added, "\t{:entries-added/%ju} "
+ "{N:/syncache entr%s added}\n");
+ p1a(tcps_sc_retransmitted, "\t\t{:retransmitted/%ju} "
+ "{N:/retransmitted}\n");
+ p1a(tcps_sc_dupsyn, "\t\t{:duplicates/%ju} {N:/dupsyn}\n");
+ p1a(tcps_sc_dropped, "\t\t{:dropped/%ju} {N:/dropped}\n");
+ p1a(tcps_sc_completed, "\t\t{:completed/%ju} {N:/completed}\n");
+ p1a(tcps_sc_bucketoverflow, "\t\t{:bucket-overflow/%ju} "
+ "{N:/bucket overflow}\n");
+ p1a(tcps_sc_cacheoverflow, "\t\t{:cache-overflow/%ju} "
+ "{N:/cache overflow}\n");
+ p1a(tcps_sc_reset, "\t\t{:reset/%ju} {N:/reset}\n");
+ p1a(tcps_sc_stale, "\t\t{:stale/%ju} {N:/stale}\n");
+ p1a(tcps_sc_aborted, "\t\t{:aborted/%ju} {N:/aborted}\n");
+ p1a(tcps_sc_badack, "\t\t{:bad-ack/%ju} {N:/badack}\n");
+ p1a(tcps_sc_unreach, "\t\t{:unreachable/%ju} {N:/unreach}\n");
+ p(tcps_sc_zonefail, "\t\t{:zone-failures/%ju} {N:/zone failure%s}\n");
+ p(tcps_sc_sendcookie, "\t{:sent-cookies/%ju} {N:/cookie%s sent}\n");
+ p(tcps_sc_recvcookie, "\t{:receivd-cookies/%ju} "
+ "{N:/cookie%s received}\n");
+
+ xo_close_container("syncache");
+
+ xo_open_container("hostcache");
+
+ p3(tcps_hc_added, "\t{:entries-added/%ju} "
+ "{N:/hostcache entr%s added}\n");
+ p1a(tcps_hc_bucketoverflow, "\t\t{:buffer-overflows/%ju} "
+ "{N:/bucket overflow}\n");
+
+ xo_close_container("hostcache");
+
+ xo_open_container("sack");
+
+ p(tcps_sack_recovery_episode, "\t{:recovery-episodes/%ju} "
+ "{N:/SACK recovery episode%s}\n");
+ p(tcps_sack_rexmits, "\t{:segment-retransmits/%ju} "
+ "{N:/segment rexmit%s in SACK recovery episodes}\n");
+ p(tcps_sack_rexmit_bytes, "\t{:byte-retransmits/%ju} "
+ "{N:/byte rexmit%s in SACK recovery episodes}\n");
+ p(tcps_sack_rcv_blocks, "\t{:received-blocks/%ju} "
+ "{N:/SACK option%s (SACK blocks) received}\n");
+ p(tcps_sack_send_blocks, "\t{:sent-option-blocks/%ju} "
+ "{N:/SACK option%s (SACK blocks) sent}\n");
+ p1a(tcps_sack_sboverflow, "\t{:scoreboard-overflows/%ju} "
+ "{N:/SACK scoreboard overflow}\n");
+
+ xo_close_container("sack");
+ xo_open_container("ecn");
+
+ p(tcps_ecn_ce, "\t{:ce-packets/%ju} "
+ "{N:/packet%s with ECN CE bit set}\n");
+ p(tcps_ecn_ect0, "\t{:ect0-packets/%ju} "
+ "{N:/packet%s with ECN ECT(0) bit set}\n");
+ p(tcps_ecn_ect1, "\t{:ect1-packets/%ju} "
+ "{N:/packet%s with ECN ECT(1) bit set}\n");
+ p(tcps_ecn_shs, "\t{:handshakes/%ju} "
+ "{N:/successful ECN handshake%s}\n");
+ p(tcps_ecn_rcwnd, "\t{:congestion-reductions/%ju} "
+ "{N:/time%s ECN reduced the congestion window}\n");
+ #undef p
+ #undef p1a
+ #undef p2
+ #undef p2a
+ #undef p3
+ xo_close_container("ecn");
+ xo_close_container("tcp");
}
/*
@@ -773,27 +877,38 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
memset(&zerostat, 0, len);
if (sysctlbyname("net.inet.udp.stats", &udpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.udp.stats");
+ xo_warn("sysctl: net.inet.udp.stats");
return;
}
} else
kread_counters(off, &udpstat, len);
- printf("%s:\n", name);
+ xo_open_container("udp");
+ xo_emit("{T:/%s}:\n", name);
+
#define p(f, m) if (udpstat.f || sflag <= 1) \
- printf("\t%ju " m, (uintmax_t)udpstat.f, plural(udpstat.f))
+ xo_emit("\t" m, (uintmax_t)udpstat.f, plural(udpstat.f))
#define p1a(f, m) if (udpstat.f || sflag <= 1) \
- printf("\t%ju " m, (uintmax_t)udpstat.f)
- p(udps_ipackets, "datagram%s received\n");
- p1a(udps_hdrops, "with incomplete header\n");
- p1a(udps_badlen, "with bad data length field\n");
- p1a(udps_badsum, "with bad checksum\n");
- p1a(udps_nosum, "with no checksum\n");
- p1a(udps_noport, "dropped due to no socket\n");
- p(udps_noportbcast,
- "broadcast/multicast datagram%s undelivered\n");
- p1a(udps_fullsock, "dropped due to full socket buffers\n");
- p1a(udpps_pcbhashmiss, "not for hashed pcb\n");
+ xo_emit("\t" m, (uintmax_t)udpstat.f)
+
+ p(udps_ipackets, "{:received-datagrams/%ju} "
+ "{N:/datagram%s received}\n");
+ p1a(udps_hdrops, "{:dropped-incomplete-headers/%ju} "
+ "{N:/with incomplete header}\n");
+ p1a(udps_badlen, "{:dropped-bad-data-length/%ju} "
+ "{N:/with bad data length field}\n");
+ p1a(udps_badsum, "{:dropped-bad-checksum/%ju} "
+ "{N:/with bad checksum}\n");
+ p1a(udps_nosum, "{:dropped-no-checksum/%ju} "
+ "{N:/with no checksum}\n");
+ p1a(udps_noport, "{:dropped-no-socket/%ju} "
+ "{N:/dropped due to no socket}\n");
+ p(udps_noportbcast, "{:dropped-broadcast-multicast/%ju} "
+ "{N:/broadcast\\/multicast datagram%s undelivered}\n");
+ p1a(udps_fullsock, "{:dropped-full-socket-buffer/%ju} "
+ "{N:/dropped due to full socket buffers}\n");
+ p1a(udpps_pcbhashmiss, "{:not-for-hashed-pcb/%ju} "
+ "{N:/not for hashed pcb}\n");
delivered = udpstat.udps_ipackets -
udpstat.udps_hdrops -
udpstat.udps_badlen -
@@ -802,13 +917,15 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
udpstat.udps_noportbcast -
udpstat.udps_fullsock;
if (delivered || sflag <= 1)
- printf("\t%ju delivered\n", (uint64_t)delivered);
- p(udps_opackets, "datagram%s output\n");
+ xo_emit("\t{:delivered-packets/%ju} {N:/delivered}\n",
+ (uint64_t)delivered);
+ p(udps_opackets, "{:output-packets/%ju} {N:/datagram%s output}\n");
/* the next statistic is cumulative in udps_noportbcast */
- p(udps_filtermcast,
- "time%s multicast source filter matched\n");
+ p(udps_filtermcast, "{:multicast-source-filter-matches/%ju} "
+ "{N:/time%s multicast source filter matched}\n");
#undef p
#undef p1a
+ xo_close_container("udp");
}
/*
@@ -826,7 +943,7 @@ carp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet.carp.stats", &carpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet.carp.stats");
+ xo_warn("sysctl: net.inet.carp.stats");
return;
}
} else {
@@ -835,31 +952,47 @@ carp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
kread_counters(off, &carpstat, len);
}
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (carpstat.f || sflag <= 1) \
- printf(m, (uintmax_t)carpstat.f, plural(carpstat.f))
+ xo_emit(m, (uintmax_t)carpstat.f, plural(carpstat.f))
#define p2(f, m) if (carpstat.f || sflag <= 1) \
- printf(m, (uintmax_t)carpstat.f)
-
- p(carps_ipackets, "\t%ju packet%s received (IPv4)\n");
- p(carps_ipackets6, "\t%ju packet%s received (IPv6)\n");
- p(carps_badttl, "\t\t%ju packet%s discarded for wrong TTL\n");
- p(carps_hdrops, "\t\t%ju packet%s shorter than header\n");
- p(carps_badsum, "\t\t%ju discarded for bad checksum%s\n");
- p(carps_badver, "\t\t%ju discarded packet%s with a bad version\n");
- p2(carps_badlen, "\t\t%ju discarded because packet too short\n");
- p2(carps_badauth, "\t\t%ju discarded for bad authentication\n");
- p2(carps_badvhid, "\t\t%ju discarded for bad vhid\n");
- p2(carps_badaddrs, "\t\t%ju discarded because of a bad address list\n");
- p(carps_opackets, "\t%ju packet%s sent (IPv4)\n");
- p(carps_opackets6, "\t%ju packet%s sent (IPv6)\n");
- p2(carps_onomem, "\t\t%ju send failed due to mbuf memory error\n");
+ xo_emit(m, (uintmax_t)carpstat.f)
+
+ p(carps_ipackets, "\t{:received-inet-packets/%ju} "
+ "{N:/packet%s received (IPv4)}\n");
+ p(carps_ipackets6, "\t{:received-inet6-packets/%ju} "
+ "{N:/packet%s received (IPv6)}\n");
+ p(carps_badttl, "\t\t{:dropped-wrong-ttl/%ju} "
+ "{N:/packet%s discarded for wrong TTL}\n");
+ p(carps_hdrops, "\t\t{:dropped-short-header/%ju} "
+ "{N:/packet%s shorter than header}\n");
+ p(carps_badsum, "\t\t{:dropped-bad-checksum/%ju} "
+ "{N:/discarded for bad checksum%s}\n");
+ p(carps_badver, "\t\t{:dropped-bad-version/%ju} "
+ "{N:/discarded packet%s with a bad version}\n");
+ p2(carps_badlen, "\t\t{:dropped-short-packet/%ju} "
+ "{N:/discarded because packet too short}\n");
+ p2(carps_badauth, "\t\t{:dropped-bad-authentication/%ju} "
+ "{N:/discarded for bad authentication}\n");
+ p2(carps_badvhid, "\t\t{:dropped-bad-vhid/%ju} "
+ "{N:/discarded for bad vhid}\n");
+ p2(carps_badaddrs, "\t\t{:dropped-bad-address-list/%ju} "
+ "{N:/discarded because of a bad address list}\n");
+ p(carps_opackets, "\t{:sent-inet-packets/%ju} "
+ "{N:/packet%s sent (IPv4)}\n");
+ p(carps_opackets6, "\t{:sent-inet6-packets/%ju} "
+ "{N:/packet%s sent (IPv6)}\n");
+ p2(carps_onomem, "\t\t{:send-failed-memory-error/%ju} "
+ "{N:/send failed due to mbuf memory error}\n");
#if notyet
- p(carps_ostates, "\t\t%s state update%s sent\n");
+ p(carps_ostates, "\t\t{:send-state-updates/%s} "
+ "{N:/state update%s sent}\n");
#endif
#undef p
#undef p2
+ xo_close_container(name);
}
/*
@@ -876,54 +1009,83 @@ ip_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
memset(&zerostat, 0, len);
if (sysctlbyname("net.inet.ip.stats", &ipstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.ip.stats");
+ xo_warn("sysctl: net.inet.ip.stats");
return;
}
} else
kread_counters(off, &ipstat, len);
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (ipstat.f || sflag <= 1) \
- printf(m, (uintmax_t )ipstat.f, plural(ipstat.f))
+ xo_emit(m, (uintmax_t )ipstat.f, plural(ipstat.f))
#define p1a(f, m) if (ipstat.f || sflag <= 1) \
- printf(m, (uintmax_t )ipstat.f)
-
- p(ips_total, "\t%ju total packet%s received\n");
- p(ips_badsum, "\t%ju bad header checksum%s\n");
- p1a(ips_toosmall, "\t%ju with size smaller than minimum\n");
- p1a(ips_tooshort, "\t%ju with data size < data length\n");
- p1a(ips_toolong, "\t%ju with ip length > max ip packet size\n");
- p1a(ips_badhlen, "\t%ju with header length < data size\n");
- p1a(ips_badlen, "\t%ju with data length < header length\n");
- p1a(ips_badoptions, "\t%ju with bad options\n");
- p1a(ips_badvers, "\t%ju with incorrect version number\n");
- p(ips_fragments, "\t%ju fragment%s received\n");
- p(ips_fragdropped, "\t%ju fragment%s dropped (dup or out of space)\n");
- p(ips_fragtimeout, "\t%ju fragment%s dropped after timeout\n");
- p(ips_reassembled, "\t%ju packet%s reassembled ok\n");
- p(ips_delivered, "\t%ju packet%s for this host\n");
- p(ips_noproto, "\t%ju packet%s for unknown/unsupported protocol\n");
- p(ips_forward, "\t%ju packet%s forwarded");
- p(ips_fastforward, " (%ju packet%s fast forwarded)");
+ xo_emit(m, (uintmax_t )ipstat.f)
+
+ p(ips_total, "\t{:received-packets/%ju} "
+ "{N:/total packet%s received}\n");
+ p(ips_badsum, "\t{:dropped-bad-checksum/%ju} "
+ "{N:/bad header checksum%s}\n");
+ p1a(ips_toosmall, "\t{:dropped-below-minimum-size/%ju} "
+ "{N:/with size smaller than minimum}\n");
+ p1a(ips_tooshort, "\t{:dropped-short-packets/%ju} "
+ "{N:/with data size < data length}\n");
+ p1a(ips_toolong, "\t{:dropped-too-long/%ju} "
+ "{N:/with ip length > max ip packet size}\n");
+ p1a(ips_badhlen, "\t{:dropped-short-header-length/%ju} "
+ "{N:/with header length < data size}\n");
+ p1a(ips_badlen, "\t{:dropped-short-data/%ju} "
+ "{N:/with data length < header length}\n");
+ p1a(ips_badoptions, "\t{:dropped-bad-options/%ju} "
+ "{N:/with bad options}\n");
+ p1a(ips_badvers, "\t{:dropped-bad-version/%ju} "
+ "{N:/with incorrect version number}\n");
+ p(ips_fragments, "\t{:received-fragments/%ju} "
+ "{N:/fragment%s received}\n");
+ p(ips_fragdropped, "\t{:dropped-fragments/%ju} "
+ "{N:/fragment%s dropped (dup or out of space)}\n");
+ p(ips_fragtimeout, "\t{:dropped-fragments-after-timeout/%ju} "
+ "{N:/fragment%s dropped after timeout}\n");
+ p(ips_reassembled, "\t{:reassembled-packets/%ju} "
+ "{N:/packet%s reassembled ok}\n");
+ p(ips_delivered, "\t{:received-local-packets/%ju} "
+ "{N:/packet%s for this host}\n");
+ p(ips_noproto, "\t{:dropped-unknown-protocol/%ju} "
+ "{N:/packet%s for unknown\\/unsupported protocol}\n");
+ p(ips_forward, "\t{:forwarded-packets/%ju} "
+ "{N:/packet%s forwarded}");
+ p(ips_fastforward, " ({:fast-forwarded-packets/%ju} "
+ "{N:/packet%s fast forwarded})");
if (ipstat.ips_forward || sflag <= 1)
- putchar('\n');
- p(ips_cantforward, "\t%ju packet%s not forwardable\n");
- p(ips_notmember,
- "\t%ju packet%s received for unknown multicast group\n");
- p(ips_redirectsent, "\t%ju redirect%s sent\n");
- p(ips_localout, "\t%ju packet%s sent from this host\n");
- p(ips_rawout, "\t%ju packet%s sent with fabricated ip header\n");
- p(ips_odropped,
- "\t%ju output packet%s dropped due to no bufs, etc.\n");
- p(ips_noroute, "\t%ju output packet%s discarded due to no route\n");
- p(ips_fragmented, "\t%ju output datagram%s fragmented\n");
- p(ips_ofragments, "\t%ju fragment%s created\n");
- p(ips_cantfrag, "\t%ju datagram%s that can't be fragmented\n");
- p(ips_nogif, "\t%ju tunneling packet%s that can't find gif\n");
- p(ips_badaddr, "\t%ju datagram%s with bad address in header\n");
+ xo_emit("\n");
+ p(ips_cantforward, "\t{:packets-cannot-forward/%ju} "
+ "{N:/packet%s not forwardable}\n");
+ p(ips_notmember, "\t{:received-unknown-multicast-group/%ju} "
+ "{N:/packet%s received for unknown multicast group}\n");
+ p(ips_redirectsent, "\t{:redirects-sent/%ju} "
+ "{N:/redirect%s sent}\n");
+ p(ips_localout, "\t{:sent-packets/%ju} "
+ "{N:/packet%s sent from this host}\n");
+ p(ips_rawout, "\t{:send-packets-fabricated-header/%ju} "
+ "{N:/packet%s sent with fabricated ip header}\n");
+ p(ips_odropped, "\t{:discard-no-mbufs/%ju} "
+ "{N:/output packet%s dropped due to no bufs, etc.}\n");
+ p(ips_noroute, "\t{:discard-no-route/%ju} "
+ "{N:/output packet%s discarded due to no route}\n");
+ p(ips_fragmented, "\t{:sent-fragments/%ju} "
+ "{N:/output datagram%s fragmented}\n");
+ p(ips_ofragments, "\t{:fragments-created/%ju} "
+ "{N:/fragment%s created}\n");
+ p(ips_cantfrag, "\t{:discard-cannot-fragment/%ju} "
+ "{N:/datagram%s that can't be fragmented}\n");
+ p(ips_nogif, "\t{:discard-tunnel-no-gif/%ju} "
+ "{N:/tunneling packet%s that can't find gif}\n");
+ p(ips_badaddr, "\t{:discard-bad-address/%ju} "
+ "{N:/datagram%s with bad address in header}\n");
#undef p
#undef p1a
+ xo_close_container(name);
}
/*
@@ -940,29 +1102,37 @@ arp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
memset(&zerostat, 0, len);
if (sysctlbyname("net.link.ether.arp.stats", &arpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.link.ether.arp.stats");
+ xo_warn("sysctl: net.link.ether.arp.stats");
return;
}
} else
kread_counters(off, &arpstat, len);
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (arpstat.f || sflag <= 1) \
- printf("\t%ju " m, (uintmax_t)arpstat.f, plural(arpstat.f))
+ xo_emit("\t" m, (uintmax_t)arpstat.f, plural(arpstat.f))
#define p2(f, m) if (arpstat.f || sflag <= 1) \
- printf("\t%ju " m, (uintmax_t)arpstat.f, pluralies(arpstat.f))
-
- p(txrequests, "ARP request%s sent\n");
- p2(txreplies, "ARP repl%s sent\n");
- p(rxrequests, "ARP request%s received\n");
- p2(rxreplies, "ARP repl%s received\n");
- p(received, "ARP packet%s received\n");
- p(dropped, "total packet%s dropped due to no ARP entry\n");
- p(timeouts, "ARP entry%s timed out\n");
- p(dupips, "Duplicate IP%s seen\n");
+ xo_emit("\t" m, (uintmax_t)arpstat.f, pluralies(arpstat.f))
+
+ p(txrequests, "{:sent-requests/%ju} {N:/ARP request%s sent}\n");
+ p2(txreplies, "{:sent-replies/%ju} {N:/ARP repl%s sent}\n");
+ p(rxrequests, "{:received-requests/%ju} "
+ "{N:/ARP request%s received}\n");
+ p2(rxreplies, "{:received-replies/%ju} "
+ "{N:/ARP repl%s received}\n");
+ p(received, "{:received-packers/%ju} "
+ "{N:/ARP packet%s received}\n");
+ p(dropped, "{:dropped-no-entry/%ju} "
+ "{N:/total packet%s dropped due to no ARP entry}\n");
+ p(timeouts, "{:entries-timeout/%ju} "
+ "{N:/ARP entry%s timed out}\n");
+ p(dupips, "{:dropped-duplicate-address/%ju} "
+ "{N:/Duplicate IP%s seen}\n");
#undef p
#undef p2
+ xo_close_container(name);
}
@@ -1027,59 +1197,89 @@ icmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
memset(&zerostat, 0, len);
if (sysctlbyname("net.inet.icmp.stats", &icmpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.icmp.stats");
+ xo_warn("sysctl: net.inet.icmp.stats");
return;
}
} else
kread_counters(off, &icmpstat, len);
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (icmpstat.f || sflag <= 1) \
- printf(m, icmpstat.f, plural(icmpstat.f))
+ xo_emit(m, icmpstat.f, plural(icmpstat.f))
#define p1a(f, m) if (icmpstat.f || sflag <= 1) \
- printf(m, icmpstat.f)
+ xo_emit(m, icmpstat.f)
#define p2(f, m) if (icmpstat.f || sflag <= 1) \
- printf(m, icmpstat.f, plurales(icmpstat.f))
+ xo_emit(m, icmpstat.f, plurales(icmpstat.f))
+
+ p(icps_error, "\t{:icmp-calls/%lu} "
+ "{N:/call%s to icmp_error}\n");
+ p(icps_oldicmp, "\t{:errors-not-from-message/%lu} "
+ "{N:/error%s not generated in response to an icmp message}\n");
- p(icps_error, "\t%lu call%s to icmp_error\n");
- p(icps_oldicmp,
- "\t%lu error%s not generated in response to an icmp message\n");
- for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
+ for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++) {
if (icmpstat.icps_outhist[i] != 0) {
if (first) {
- printf("\tOutput histogram:\n");
+ xo_open_list("output-histogram");
+ xo_emit("\tOutput histogram:\n");
first = 0;
}
+ xo_open_instance("output-histogram");
if (icmpnames[i] != NULL)
- printf("\t\t%s: %lu\n", icmpnames[i],
- icmpstat.icps_outhist[i]);
+ xo_emit("\t\t{k:name/%s}: {:count/%lu}\n",
+ icmpnames[i], icmpstat.icps_outhist[i]);
else
- printf("\t\tunknown ICMP #%d: %lu\n", i,
- icmpstat.icps_outhist[i]);
+ xo_emit("\t\tunknown ICMP #{k:name/%d}: "
+ "{:count/%lu}\n",
+ i, icmpstat.icps_outhist[i]);
+ xo_close_instance("output-histogram");
}
- p(icps_badcode, "\t%lu message%s with bad code fields\n");
- p(icps_tooshort, "\t%lu message%s less than the minimum length\n");
- p(icps_checksum, "\t%lu message%s with bad checksum\n");
- p(icps_badlen, "\t%lu message%s with bad length\n");
- p1a(icps_bmcastecho, "\t%lu multicast echo requests ignored\n");
- p1a(icps_bmcasttstamp, "\t%lu multicast timestamp requests ignored\n");
- for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
+ }
+ if (!first)
+ xo_close_list("output-histogram");
+
+ p(icps_badcode, "\t{:dropped-bad-code/%lu} "
+ "{N:/message%s with bad code fields}\n");
+ p(icps_tooshort, "\t{:dropped-too-short/%lu} "
+ "{N:/message%s less than the minimum length}\n");
+ p(icps_checksum, "\t{:dropped-bad-checksum/%lu} "
+ "{N:/message%s with bad checksum}\n");
+ p(icps_badlen, "\t{:dropped-bad-length/%lu} "
+ "{N:/message%s with bad length}\n");
+ p1a(icps_bmcastecho, "\t{:dropped-multicast-echo/%lu} "
+ "{N:/multicast echo requests ignored}\n");
+ p1a(icps_bmcasttstamp, "\t{:dropped-multicast-timestamp/%lu} "
+ "{N:/multicast timestamp requests ignored}\n");
+
+ for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++) {
if (icmpstat.icps_inhist[i] != 0) {
if (first) {
- printf("\tInput histogram:\n");
+ xo_open_list("input-histogram");
+ xo_emit("\tInput histogram:\n");
first = 0;
}
+ xo_open_instance("input-histogram");
if (icmpnames[i] != NULL)
- printf("\t\t%s: %lu\n", icmpnames[i],
- icmpstat.icps_inhist[i]);
+ xo_emit("\t\t{k:name/%s}: {:count/%lu}\n",
+ icmpnames[i],
+ icmpstat.icps_inhist[i]);
else
- printf("\t\tunknown ICMP #%d: %lu\n", i,
- icmpstat.icps_inhist[i]);
+ xo_emit(
+ "\t\tunknown ICMP #{k:name/%d}: {:count/%lu}\n",
+ i, icmpstat.icps_inhist[i]);
+ xo_close_instance("input-histogram");
}
- p(icps_reflect, "\t%lu message response%s generated\n");
- p2(icps_badaddr, "\t%lu invalid return address%s\n");
- p(icps_noroute, "\t%lu no return route%s\n");
+ }
+ if (!first)
+ xo_close_list("input-histogram");
+
+ p(icps_reflect, "\t{:sent-packets/%lu} "
+ "{N:/message response%s generated}\n");
+ p2(icps_badaddr, "\t{:discard-invalid-return-address/%lu} "
+ "{N:/invalid return address%s}\n");
+ p(icps_noroute, "\t{:discard-no-route/%lu} "
+ "{N:/no return route%s}\n");
#undef p
#undef p1a
#undef p2
@@ -1088,9 +1288,11 @@ icmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet.icmp.maskrepl", &i, &len, NULL, 0) <
0)
return;
- printf("\tICMP address mask responses are %sabled\n",
- i ? "en" : "dis");
+ xo_emit("\tICMP address mask responses are "
+ "{q:icmp-address-responses/%sabled}\n", i ? "en" : "dis");
}
+
+ xo_close_container(name);
}
/*
@@ -1108,7 +1310,7 @@ igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
memset(&zerostat, 0, len);
if (sysctlbyname("net.inet.igmp.stats", &igmpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.igmp.stats");
+ xo_warn("sysctl: net.inet.igmp.stats");
return;
}
} else {
@@ -1117,41 +1319,59 @@ igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
}
if (igmpstat.igps_version != IGPS_VERSION_3) {
- warnx("%s: version mismatch (%d != %d)", __func__,
+ xo_warnx("%s: version mismatch (%d != %d)", __func__,
igmpstat.igps_version, IGPS_VERSION_3);
}
if (igmpstat.igps_len != IGPS_VERSION3_LEN) {
- warnx("%s: size mismatch (%d != %d)", __func__,
+ xo_warnx("%s: size mismatch (%d != %d)", __func__,
igmpstat.igps_len, IGPS_VERSION3_LEN);
}
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p64(f, m) if (igmpstat.f || sflag <= 1) \
- printf(m, (uintmax_t) igmpstat.f, plural(igmpstat.f))
+ xo_emit(m, (uintmax_t) igmpstat.f, plural(igmpstat.f))
#define py64(f, m) if (igmpstat.f || sflag <= 1) \
- printf(m, (uintmax_t) igmpstat.f, pluralies(igmpstat.f))
- p64(igps_rcv_total, "\t%ju message%s received\n");
- p64(igps_rcv_tooshort, "\t%ju message%s received with too few bytes\n");
- p64(igps_rcv_badttl, "\t%ju message%s received with wrong TTL\n");
- p64(igps_rcv_badsum, "\t%ju message%s received with bad checksum\n");
- py64(igps_rcv_v1v2_queries, "\t%ju V1/V2 membership quer%s received\n");
- py64(igps_rcv_v3_queries, "\t%ju V3 membership quer%s received\n");
- py64(igps_rcv_badqueries,
- "\t%ju membership quer%s received with invalid field(s)\n");
- py64(igps_rcv_gen_queries, "\t%ju general quer%s received\n");
- py64(igps_rcv_group_queries, "\t%ju group quer%s received\n");
- py64(igps_rcv_gsr_queries, "\t%ju group-source quer%s received\n");
- py64(igps_drop_gsr_queries, "\t%ju group-source quer%s dropped\n");
- p64(igps_rcv_reports, "\t%ju membership report%s received\n");
- p64(igps_rcv_badreports,
- "\t%ju membership report%s received with invalid field(s)\n");
- p64(igps_rcv_ourreports,
-"\t%ju membership report%s received for groups to which we belong\n");
- p64(igps_rcv_nora, "\t%ju V3 report%s received without Router Alert\n");
- p64(igps_snd_reports, "\t%ju membership report%s sent\n");
+ xo_emit(m, (uintmax_t) igmpstat.f, pluralies(igmpstat.f))
+
+ p64(igps_rcv_total, "\t{:received-messages/%ju} "
+ "{N:/message%s received}\n");
+ p64(igps_rcv_tooshort, "\t{:dropped-too-short/%ju} "
+ "{N:/message%s received with too few bytes}\n");
+ p64(igps_rcv_badttl, "\t{:dropped-wrong-ttl/%ju} "
+ "{N:/message%s received with wrong TTL}\n");
+ p64(igps_rcv_badsum, "\t{:dropped-bad-checksum/%ju} "
+ "{N:/message%s received with bad checksum}\n");
+ py64(igps_rcv_v1v2_queries, "\t{:received-membership-queries/%ju} "
+ "{N:/V1\\/V2 membership quer%s received}\n");
+ py64(igps_rcv_v3_queries, "\t{:received-v3-membership-queries/%ju} "
+ "{N:/V3 membership quer%s received}\n");
+ py64(igps_rcv_badqueries, "\t{:dropped-membership-queries/%ju} "
+ "{N:/membership quer%s received with invalid field(s)}\n");
+ py64(igps_rcv_gen_queries, "\t{:received-general-queries/%ju} "
+ "{N:/general quer%s received}\n");
+ py64(igps_rcv_group_queries, "\t{:received-group-queries/%ju} "
+ "{N:/group quer%s received}\n");
+ py64(igps_rcv_gsr_queries, "\t{:received-group-source-queries/%ju} "
+ "{N:/group-source quer%s received}\n");
+ py64(igps_drop_gsr_queries, "\t{:dropped-group-source-queries/%ju} "
+ "{N:/group-source quer%s dropped}\n");
+ p64(igps_rcv_reports, "\t{:received-membership-requests/%ju} "
+ "{N:/membership report%s received}\n");
+ p64(igps_rcv_badreports, "\t{:dropped-membership-reports/%ju} "
+ "{N:/membership report%s received with invalid field(s)}\n");
+ p64(igps_rcv_ourreports, "\t"
+ "{:received-membership-reports-matching/%ju} "
+ "{N:/membership report%s received for groups to which we belong}"
+ "\n");
+ p64(igps_rcv_nora, "\t{:received-v3-reports-no-router-alert/%ju} "
+ "{N:/V3 report%s received without Router Alert}\n");
+ p64(igps_snd_reports, "\t{:sent-membership-reports/%ju} "
+ "{N:/membership report%s sent}\n");
#undef p64
#undef py64
+ xo_close_container(name);
}
/*
@@ -1170,7 +1390,7 @@ pim_stats(u_long off __unused, const char *name, int af1 __unused,
if (sysctlbyname("net.inet.pim.stats", &pimstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet.pim.stats");
+ xo_warn("sysctl: net.inet.pim.stats");
return;
}
} else {
@@ -1179,38 +1399,56 @@ pim_stats(u_long off __unused, const char *name, int af1 __unused,
kread_counters(off, &pimstat, len);
}
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (pimstat.f || sflag <= 1) \
- printf(m, (uintmax_t)pimstat.f, plural(pimstat.f))
+ xo_emit(m, (uintmax_t)pimstat.f, plural(pimstat.f))
#define py(f, m) if (pimstat.f || sflag <= 1) \
- printf(m, (uintmax_t)pimstat.f, pimstat.f != 1 ? "ies" : "y")
- p(pims_rcv_total_msgs, "\t%ju message%s received\n");
- p(pims_rcv_total_bytes, "\t%ju byte%s received\n");
- p(pims_rcv_tooshort, "\t%ju message%s received with too few bytes\n");
- p(pims_rcv_badsum, "\t%ju message%s received with bad checksum\n");
- p(pims_rcv_badversion, "\t%ju message%s received with bad version\n");
- p(pims_rcv_registers_msgs, "\t%ju data register message%s received\n");
- p(pims_rcv_registers_bytes, "\t%ju data register byte%s received\n");
- p(pims_rcv_registers_wrongiif,
- "\t%ju data register message%s received on wrong iif\n");
- p(pims_rcv_badregisters, "\t%ju bad register%s received\n");
- p(pims_snd_registers_msgs, "\t%ju data register message%s sent\n");
- p(pims_snd_registers_bytes, "\t%ju data register byte%s sent\n");
+ xo_emit(m, (uintmax_t)pimstat.f, pimstat.f != 1 ? "ies" : "y")
+
+ p(pims_rcv_total_msgs, "\t{:received-messages/%ju} "
+ "{N:/message%s received}\n");
+ p(pims_rcv_total_bytes, "\t{:received-bytes/%ju} "
+ "{N:/byte%s received}\n");
+ p(pims_rcv_tooshort, "\t{:dropped-too-short/%ju} "
+ "{N:/message%s received with too few bytes}\n");
+ p(pims_rcv_badsum, "\t{:dropped-bad-checksum/%ju} "
+ "{N:/message%s received with bad checksum}\n");
+ p(pims_rcv_badversion, "\t{:dropped-bad-version/%ju} "
+ "{N:/message%s received with bad version}\n");
+ p(pims_rcv_registers_msgs, "\t{:received-data-register-messages/%ju} "
+ "{N:/data register message%s received}\n");
+ p(pims_rcv_registers_bytes, "\t{:received-data-register-bytes/%ju} "
+ "{N:/data register byte%s received}\n");
+ p(pims_rcv_registers_wrongiif, "\t"
+ "{:received-data-register-wrong-interface/%ju} "
+ "{N:/data register message%s received on wrong iif}\n");
+ p(pims_rcv_badregisters, "\t{:received-bad-registers/%ju} "
+ "{N:/bad register%s received}\n");
+ p(pims_snd_registers_msgs, "\t{:sent-data-register-messages/%ju} "
+ "{N:/data register message%s sent}\n");
+ p(pims_snd_registers_bytes, "\t{:sent-data-register-bytes/%ju} "
+ "{N:/data register byte%s sent}\n");
#undef p
#undef py
+ xo_close_container(name);
}
/*
* Pretty print an Internet address (net address + port).
*/
void
-inetprint(struct in_addr *in, int port, const char *proto, int num_port)
+inetprint(const char *container, struct in_addr *in, int port,
+ const char *proto, int num_port)
{
struct servent *sp = 0;
char line[80], *cp;
int width;
+ if (container)
+ xo_open_container(container);
+
if (Wflag)
sprintf(line, "%s.", inetname(in));
else
@@ -1224,9 +1462,16 @@ inetprint(struct in_addr *in, int port, const char *proto, int num_port)
sprintf(cp, "%d ", ntohs((u_short)port));
width = (Aflag && !Wflag) ? 18 : 22;
if (Wflag)
- printf("%-*s ", width, line);
+ xo_emit("{d:target/%-*s} ", width, line);
else
- printf("%-*.*s ", width, width, line);
+ xo_emit("{d:target/%-*.*s} ", width, width, line);
+
+ int alen = cp - line - 1, plen = strlen(cp) - 1;
+ xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen,
+ plen, cp);
+
+ if (container)
+ xo_close_container(container);
}
/*
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index 96fdcaf..0d2006a 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -65,9 +65,11 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "netstat.h"
struct socket sockb;
@@ -372,153 +374,246 @@ ip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet6.ip6.stats", &ip6stat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet6.ip6.stats");
+ xo_warn("sysctl: net.inet6.ip6.stats");
return;
}
} else
kread_counters(off, &ip6stat, len);
-
- printf("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (ip6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)ip6stat.f, plural(ip6stat.f))
+ xo_emit(m, (uintmax_t)ip6stat.f, plural(ip6stat.f))
#define p1a(f, m) if (ip6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)ip6stat.f)
-
- p(ip6s_total, "\t%ju total packet%s received\n");
- p1a(ip6s_toosmall, "\t%ju with size smaller than minimum\n");
- p1a(ip6s_tooshort, "\t%ju with data size < data length\n");
- p1a(ip6s_badoptions, "\t%ju with bad options\n");
- p1a(ip6s_badvers, "\t%ju with incorrect version number\n");
- p(ip6s_fragments, "\t%ju fragment%s received\n");
- p(ip6s_fragdropped, "\t%ju fragment%s dropped (dup or out of space)\n");
- p(ip6s_fragtimeout, "\t%ju fragment%s dropped after timeout\n");
- p(ip6s_fragoverflow, "\t%ju fragment%s that exceeded limit\n");
- p(ip6s_reassembled, "\t%ju packet%s reassembled ok\n");
- p(ip6s_delivered, "\t%ju packet%s for this host\n");
- p(ip6s_forward, "\t%ju packet%s forwarded\n");
- p(ip6s_cantforward, "\t%ju packet%s not forwardable\n");
- p(ip6s_redirectsent, "\t%ju redirect%s sent\n");
- p(ip6s_localout, "\t%ju packet%s sent from this host\n");
- p(ip6s_rawout, "\t%ju packet%s sent with fabricated ip header\n");
- p(ip6s_odropped, "\t%ju output packet%s dropped due to no bufs, etc.\n");
- p(ip6s_noroute, "\t%ju output packet%s discarded due to no route\n");
- p(ip6s_fragmented, "\t%ju output datagram%s fragmented\n");
- p(ip6s_ofragments, "\t%ju fragment%s created\n");
- p(ip6s_cantfrag, "\t%ju datagram%s that can't be fragmented\n");
- p(ip6s_badscope, "\t%ju packet%s that violated scope rules\n");
- p(ip6s_notmember, "\t%ju multicast packet%s which we don't join\n");
+ xo_emit(m, (uintmax_t)ip6stat.f)
+
+ p(ip6s_total, "\t{:received-packets/%ju} "
+ "{N:/total packet%s received}\n");
+ p1a(ip6s_toosmall, "\t{:dropped-below-minimum-size/%ju} "
+ "{N:/with size smaller than minimum}\n");
+ p1a(ip6s_tooshort, "\t{:dropped-short-packets/%ju} "
+ "{N:/with data size < data length}\n");
+ p1a(ip6s_badoptions, "\t{:dropped-bad-options/%ju} "
+ "{N:/with bad options}\n");
+ p1a(ip6s_badvers, "\t{:dropped-bad-version/%ju} "
+ "{N:/with incorrect version number}\n");
+ p(ip6s_fragments, "\t{:received-fragments/%ju} "
+ "{N:/fragment%s received}\n");
+ p(ip6s_fragdropped, "\t{:dropped-fragment/%ju} "
+ "{N:/fragment%s dropped (dup or out of space)}\n");
+ p(ip6s_fragtimeout, "\t{:dropped-fragment-after-timeout/%ju} "
+ "{N:/fragment%s dropped after timeout}\n");
+ p(ip6s_fragoverflow, "\t{:dropped-fragments-overflow/%ju} "
+ "{N:/fragment%s that exceeded limit}\n");
+ p(ip6s_reassembled, "\t{:reassembled-packets/%ju} "
+ "{N:/packet%s reassembled ok}\n");
+ p(ip6s_delivered, "\t{:received-local-packets/%ju} "
+ "{N:/packet%s for this host}\n");
+ p(ip6s_forward, "\t{:forwarded-packets/%ju} "
+ "{N:/packet%s forwarded}\n");
+ p(ip6s_cantforward, "\t{:packets-not-forwardable/%ju} "
+ "{N:/packet%s not forwardable}\n");
+ p(ip6s_redirectsent, "\t{:sent-redirects/%ju} "
+ "{N:/redirect%s sent}\n");
+ p(ip6s_localout, "\t{:sent-packets/%ju} "
+ "{N:/packet%s sent from this host}\n");
+ p(ip6s_rawout, "\t{:send-packets-fabricated-header/%ju} "
+ "{N:/packet%s sent with fabricated ip header}\n");
+ p(ip6s_odropped, "\t{:discard-no-mbufs/%ju} "
+ "{N:/output packet%s dropped due to no bufs, etc.}\n");
+ p(ip6s_noroute, "\t{:discard-no-route/%ju} "
+ "{N:/output packet%s discarded due to no route}\n");
+ p(ip6s_fragmented, "\t{:sent-fragments/%ju} "
+ "{N:/output datagram%s fragmented}\n");
+ p(ip6s_ofragments, "\t{:fragments-created/%ju} "
+ "{N:/fragment%s created}\n");
+ p(ip6s_cantfrag, "\t{:discard-cannot-fragment/%ju} "
+ "{N:/datagram%s that can't be fragmented}\n");
+ p(ip6s_badscope, "\t{:discard-scope-violations/%ju} "
+ "{N:/packet%s that violated scope rules}\n");
+ p(ip6s_notmember, "\t{:multicast-no-join-packets/%ju} "
+ "{N:/multicast packet%s which we don't join}\n");
for (first = 1, i = 0; i < IP6S_HDRCNT; i++)
if (ip6stat.ip6s_nxthist[i] != 0) {
if (first) {
- printf("\tInput histogram:\n");
+ xo_emit("\t{T:Input histogram}:\n");
+ xo_open_list("input-histogram");
first = 0;
}
- printf("\t\t%s: %ju\n", ip6nh[i],
+ xo_open_instance("input-histogram");
+ xo_emit("\t\t{k:name/%s}: {:count/%ju}\n", ip6nh[i],
(uintmax_t)ip6stat.ip6s_nxthist[i]);
+ xo_close_instance("input-histogram");
}
- printf("\tMbuf statistics:\n");
- printf("\t\t%ju one mbuf\n", (uintmax_t)ip6stat.ip6s_m1);
+ if (!first)
+ xo_close_list("input-histogram");
+
+ xo_open_container("mbuf-statistics");
+ xo_emit("\t{T:Mbuf statistics}:\n");
+ xo_emit("\t\t{:one-mbuf/%ju} {N:/one mbuf}\n",
+ (uintmax_t)ip6stat.ip6s_m1);
for (first = 1, i = 0; i < IP6S_M2MMAX; i++) {
char ifbuf[IFNAMSIZ];
if (ip6stat.ip6s_m2m[i] != 0) {
if (first) {
- printf("\t\ttwo or more mbuf:\n");
+ xo_emit("\t\t{N:two or more mbuf}:\n");
+ xo_open_list("mbuf-data");
first = 0;
}
- printf("\t\t\t%s= %ju\n",
+ xo_open_instance("mbuf-data");
+ xo_emit("\t\t\t{k:name/%s}= {:count/%ju}\n",
if_indextoname(i, ifbuf),
(uintmax_t)ip6stat.ip6s_m2m[i]);
+ xo_close_instance("mbuf-data");
}
}
- printf("\t\t%ju one ext mbuf\n",
+ if (!first)
+ xo_close_list("mbuf-data");
+ xo_emit("\t\t{:one-extra-mbuf/%ju} {N:one ext mbuf}\n",
(uintmax_t)ip6stat.ip6s_mext1);
- printf("\t\t%ju two or more ext mbuf\n",
- (uintmax_t)ip6stat.ip6s_mext2m);
- p(ip6s_exthdrtoolong,
- "\t%ju packet%s whose headers are not contiguous\n");
- p(ip6s_nogif, "\t%ju tunneling packet%s that can't find gif\n");
- p(ip6s_toomanyhdr,
- "\t%ju packet%s discarded because of too many headers\n");
+ xo_emit("\t\t{:two-or-more-extra-mbufs/%ju} "
+ "{N:/two or more ext mbuf}\n", (uintmax_t)ip6stat.ip6s_mext2m);
+ xo_close_container("mbuf-statistics");
+
+ p(ip6s_exthdrtoolong, "\t{:dropped-header-too-long/%ju} "
+ "{N:/packet%s whose headers are not contiguous}\n");
+ p(ip6s_nogif, "\t{:discard-tunnel-no-gif/%ju} "
+ "{N:/tunneling packet%s that can't find gif}\n");
+ p(ip6s_toomanyhdr, "\t{:dropped-too-many-headers/%ju} "
+ "{N:/packet%s discarded because of too many headers}\n");
/* for debugging source address selection */
#define PRINT_SCOPESTAT(s,i) do {\
switch(i) { /* XXX hardcoding in each case */\
case 1:\
- p(s, "\t\t%ju interface-local%s\n");\
+ p(s, "\t\t{ke:name/interface-locals}{:count/%ju} " \
+ "{N:/interface-local%s}\n"); \
break;\
case 2:\
- p(s,"\t\t%ju link-local%s\n");\
+ p(s,"\t\t{ke:name/link-locals}{:count/%ju} " \
+ "{N:/link-local%s}\n"); \
break;\
case 5:\
- p(s,"\t\t%ju site-local%s\n");\
+ p(s,"\t\t{ke:name/site-locals}{:count/%ju} " \
+ "{N:/site-local%s}\n");\
break;\
case 14:\
- p(s,"\t\t%ju global%s\n");\
+ p(s,"\t\t{ke:name/globals}{:count/%ju} " \
+ "{N:/global%s}\n");\
break;\
default:\
- printf("\t\t%ju addresses scope=%x\n",\
- (uintmax_t)ip6stat.s, i);\
+ xo_emit("\t\t{qke:name/%x}{:count/%ju} " \
+ "addresses scope=%x\n",\
+ i, (uintmax_t)ip6stat.s, i); \
}\
} while (0);
- p(ip6s_sources_none,
- "\t%ju failure%s of source address selection\n");
+ xo_open_container("source-address-selection");
+ p(ip6s_sources_none, "\t{:address-selection-failures/%ju} "
+ "{N:/failure%s of source address selection}\n");
+
for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_sameif[i]) {
if (first) {
- printf("\tsource addresses on an outgoing I/F\n");
+ xo_open_list("outgoing-interface");
+ xo_emit("\tsource addresses on an outgoing "
+ "I/F\n");
first = 0;
}
+ xo_open_instance("outgoing-interface");
PRINT_SCOPESTAT(ip6s_sources_sameif[i], i);
+ xo_close_instance("outgoing-interface");
}
}
+ if (!first)
+ xo_close_list("outgoing-interface");
+
for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_otherif[i]) {
if (first) {
- printf("\tsource addresses on a non-outgoing I/F\n");
+ xo_open_list("non-outgoing-interface");
+ xo_emit("\tsource addresses on a non-outgoing "
+ "I/F\n");
first = 0;
}
+ xo_open_instance("non-outgoing-interface");
PRINT_SCOPESTAT(ip6s_sources_otherif[i], i);
+ xo_close_instance("non-outgoing-interface");
}
}
+ if (!first)
+ xo_close_list("non-outgoing-interface");
+
for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_samescope[i]) {
if (first) {
- printf("\tsource addresses of same scope\n");
+ xo_open_list("same-source");
+ xo_emit("\tsource addresses of same scope\n");
first = 0;
}
+ xo_open_instance("same-source");
PRINT_SCOPESTAT(ip6s_sources_samescope[i], i);
+ xo_close_instance("same-source");
}
}
+ if (!first)
+ xo_close_list("same-source");
+
for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_otherscope[i]) {
if (first) {
- printf("\tsource addresses of a different scope\n");
+ xo_open_list("different-scope");
+ xo_emit("\tsource addresses of a different "
+ "scope\n");
first = 0;
}
+ xo_open_instance("different-scope");
PRINT_SCOPESTAT(ip6s_sources_otherscope[i], i);
+ xo_close_instance("different-scope");
}
}
+ if (!first)
+ xo_close_list("different-scope");
+
for (first = 1, i = 0; i < IP6S_SCOPECNT; i++) {
if (ip6stat.ip6s_sources_deprecated[i]) {
if (first) {
- printf("\tdeprecated source addresses\n");
+ xo_open_list("deprecated-source");
+ xo_emit("\tdeprecated source addresses\n");
first = 0;
}
+ xo_open_instance("deprecated-source");
PRINT_SCOPESTAT(ip6s_sources_deprecated[i], i);
+ xo_close_instance("deprecated-source");
}
}
+ if (!first)
+ xo_close_list("deprecated-source");
- printf("\tSource addresses selection rule applied:\n");
- for (i = 0; i < IP6S_RULESMAX; i++) {
- if (ip6stat.ip6s_sources_rule[i])
- printf("\t\t%ju %s\n",
- (uintmax_t)ip6stat.ip6s_sources_rule[i],
- srcrule_str[i]);
+ for (first = 1, i = 0; i < IP6S_RULESMAX; i++) {
+ if (ip6stat.ip6s_sources_rule[i]) {
+ if (first) {
+ xo_open_list("rules-applied");
+ xo_emit("\t{T:Source addresses selection "
+ "rule applied}:\n");
+ first = 0;
+ }
+ xo_open_instance("rules-applied");
+ xo_emit("\t\t{ke:name/%s}{:count/%ju} {d:name/%s}\n",
+ srcrule_str[i],
+ (uintmax_t)ip6stat.ip6s_sources_rule[i],
+ srcrule_str[i]);
+ xo_close_instance("rules-applied");
+ }
}
+ if (!first)
+ xo_close_list("rules-applied");
+
+ xo_close_container("source-address-selection");
+
#undef p
#undef p1a
+ xo_close_container(name);
}
/*
@@ -529,52 +624,74 @@ ip6_ifstats(char *ifname)
{
struct in6_ifreq ifr;
int s;
-#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
- printf(m, (uintmax_t)ifr.ifr_ifru.ifru_stat.f, plural(ifr.ifr_ifru.ifru_stat.f))
-#define p_5(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
- printf(m, (uintmax_t)ip6stat.f)
+
+#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
+ xo_emit(m, (uintmax_t)ifr.ifr_ifru.ifru_stat.f, \
+ plural(ifr.ifr_ifru.ifru_stat.f))
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- perror("Warning: socket(AF_INET6)");
+ xo_warn("Warning: socket(AF_INET6)");
return;
}
strcpy(ifr.ifr_name, ifname);
if (ioctl(s, SIOCGIFSTAT_IN6, (char *)&ifr) < 0) {
if (errno != EPFNOSUPPORT)
- perror("Warning: ioctl(SIOCGIFSTAT_IN6)");
+ xo_warn("Warning: ioctl(SIOCGIFSTAT_IN6)");
goto end;
}
- printf("ip6 on %s:\n", ifr.ifr_name);
- p(ifs6_in_receive, "\t%ju total input datagram%s\n");
- p(ifs6_in_hdrerr, "\t%ju datagram%s with invalid header received\n");
- p(ifs6_in_toobig, "\t%ju datagram%s exceeded MTU received\n");
- p(ifs6_in_noroute, "\t%ju datagram%s with no route received\n");
- p(ifs6_in_addrerr, "\t%ju datagram%s with invalid dst received\n");
- p(ifs6_in_protounknown, "\t%ju datagram%s with unknown proto received\n");
- p(ifs6_in_truncated, "\t%ju truncated datagram%s received\n");
- p(ifs6_in_discard, "\t%ju input datagram%s discarded\n");
- p(ifs6_in_deliver,
- "\t%ju datagram%s delivered to an upper layer protocol\n");
- p(ifs6_out_forward, "\t%ju datagram%s forwarded to this interface\n");
- p(ifs6_out_request,
- "\t%ju datagram%s sent from an upper layer protocol\n");
- p(ifs6_out_discard, "\t%ju total discarded output datagram%s\n");
- p(ifs6_out_fragok, "\t%ju output datagram%s fragmented\n");
- p(ifs6_out_fragfail, "\t%ju output datagram%s failed on fragment\n");
- p(ifs6_out_fragcreat, "\t%ju output datagram%s succeeded on fragment\n");
- p(ifs6_reass_reqd, "\t%ju incoming datagram%s fragmented\n");
- p(ifs6_reass_ok, "\t%ju datagram%s reassembled\n");
- p(ifs6_reass_fail, "\t%ju datagram%s failed on reassembly\n");
- p(ifs6_in_mcast, "\t%ju multicast datagram%s received\n");
- p(ifs6_out_mcast, "\t%ju multicast datagram%s sent\n");
-
- end:
- close(s);
+ xo_emit("{T:/ip6 on %s}:\n", ifr.ifr_name);
+
+ xo_open_instance("ip6-interface-statistics");
+ xo_emit("{ke:name/%s}", ifr.ifr_name);
+
+ p(ifs6_in_receive, "\t{:received-packets/%ju} "
+ "{N:/total input datagram%s}\n");
+ p(ifs6_in_hdrerr, "\t{:dropped-invalid-header/%ju} "
+ "{N:/datagram%s with invalid header received}\n");
+ p(ifs6_in_toobig, "\t{:dropped-mtu-exceeded/%ju} "
+ "{N:/datagram%s exceeded MTU received}\n");
+ p(ifs6_in_noroute, "\t{:dropped-no-route/%ju} "
+ "{N:/datagram%s with no route received}\n");
+ p(ifs6_in_addrerr, "\t{:dropped-invalid-destination/%ju} "
+ "{N:/datagram%s with invalid dst received}\n");
+ p(ifs6_in_protounknown, "\t{:dropped-unknown-protocol/%ju} "
+ "{N:/datagram%s with unknown proto received}\n");
+ p(ifs6_in_truncated, "\t{:dropped-truncated/%ju} "
+ "{N:/truncated datagram%s received}\n");
+ p(ifs6_in_discard, "\t{:dropped-discarded/%ju} "
+ "{N:/input datagram%s discarded}\n");
+ p(ifs6_in_deliver, "\t{:received-valid-packets/%ju} "
+ "{N:/datagram%s delivered to an upper layer protocol}\n");
+ p(ifs6_out_forward, "\t{:sent-forwarded/%ju} "
+ "{N:/datagram%s forwarded to this interface}\n");
+ p(ifs6_out_request, "\t{:sent-packets/%ju} "
+ "{N:/datagram%s sent from an upper layer protocol}\n");
+ p(ifs6_out_discard, "\t{:discard-packets/%ju} "
+ "{N:/total discarded output datagram%s}\n");
+ p(ifs6_out_fragok, "\t{:discard-fragments/%ju} "
+ "{N:/output datagram%s fragmented}\n");
+ p(ifs6_out_fragfail, "\t{:fragments-failed/%ju} "
+ "{N:/output datagram%s failed on fragment}\n");
+ p(ifs6_out_fragcreat, "\t{:fragments-created/%ju} "
+ "{N:/output datagram%s succeeded on fragment}\n");
+ p(ifs6_reass_reqd, "\t{:reassembly-required/%ju} "
+ "{N:/incoming datagram%s fragmented}\n");
+ p(ifs6_reass_ok, "\t{:reassembled-packets/%ju} "
+ "{N:/datagram%s reassembled}\n");
+ p(ifs6_reass_fail, "\t{:reassembly-failed/%ju} "
+ "{N:/datagram%s failed on reassembly}\n");
+ p(ifs6_in_mcast, "\t{:received-multicast/%ju} "
+ "{N:/multicast datagram%s received}\n");
+ p(ifs6_out_mcast, "\t{:sent-multicast/%ju} "
+ "{N:/multicast datagram%s sent}\n");
+
+ end:
+ xo_close_instance("ip6-interface-statistics");
+ close(s);
#undef p
-#undef p_5
}
static const char *icmp6names[] = {
@@ -854,76 +971,118 @@ icmp6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet6.icmp6.stats", &icmp6stat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet6.icmp6.stats");
+ xo_warn("sysctl: net.inet6.icmp6.stats");
return;
}
} else
kread_counters(off, &icmp6stat, len);
- printf("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
+ xo_open_container(name);
#define p(f, m) if (icmp6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)icmp6stat.f, plural(icmp6stat.f))
+ xo_emit(m, (uintmax_t)icmp6stat.f, plural(icmp6stat.f))
#define p_5(f, m) if (icmp6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)icmp6stat.f)
+ xo_emit(m, (uintmax_t)icmp6stat.f)
- p(icp6s_error, "\t%ju call%s to icmp6_error\n");
- p(icp6s_canterror,
- "\t%ju error%s not generated in response to an icmp6 message\n");
- p(icp6s_toofreq,
- "\t%ju error%s not generated because of rate limitation\n");
+ p(icp6s_error, "\t{:icmp6-calls/%ju} "
+ "{N:/call%s to icmp6_error}\n");
+ p(icp6s_canterror, "\t{:errors-not-generated-from-message/%ju} "
+ "{N:/error%s not generated in response to an icmp6 message}\n");
+ p(icp6s_toofreq, "\t{:errors-discarded-by-rate-limitation/%ju} "
+ "{N:/error%s not generated because of rate limitation}\n");
#define NELEM (int)(sizeof(icmp6stat.icp6s_outhist)/sizeof(icmp6stat.icp6s_outhist[0]))
for (first = 1, i = 0; i < NELEM; i++)
if (icmp6stat.icp6s_outhist[i] != 0) {
if (first) {
- printf("\tOutput histogram:\n");
+ xo_open_list("output-histogram");
+ xo_emit("\t{T:Output histogram}:\n");
first = 0;
}
- printf("\t\t%s: %ju\n", icmp6names[i],
+ xo_open_instance("output-histogram");
+ xo_emit("\t\t{k:name/%s}: {:count/%ju}\n",
+ icmp6names[i],
(uintmax_t)icmp6stat.icp6s_outhist[i]);
+ xo_close_instance("output-histogram");
}
+ if (!first)
+ xo_close_list("output-histogram");
#undef NELEM
- p(icp6s_badcode, "\t%ju message%s with bad code fields\n");
- p(icp6s_tooshort, "\t%ju message%s < minimum length\n");
- p(icp6s_checksum, "\t%ju bad checksum%s\n");
- p(icp6s_badlen, "\t%ju message%s with bad length\n");
+
+ p(icp6s_badcode, "\t{:dropped-bad-code/%ju} "
+ "{N:/message%s with bad code fields}\n");
+ p(icp6s_tooshort, "\t{:dropped-too-short/%ju} "
+ "{N:/message%s < minimum length}\n");
+ p(icp6s_checksum, "\t{:dropped-bad-checksum/%ju} "
+ "{N:/bad checksum%s}\n");
+ p(icp6s_badlen, "\t{:dropped-bad-length/%ju} "
+ "{N:/message%s with bad length}\n");
#define NELEM (int)(sizeof(icmp6stat.icp6s_inhist)/sizeof(icmp6stat.icp6s_inhist[0]))
for (first = 1, i = 0; i < NELEM; i++)
if (icmp6stat.icp6s_inhist[i] != 0) {
if (first) {
- printf("\tInput histogram:\n");
+ xo_open_list("input-histogram");
+ xo_emit("\t{T:Input histogram}:\n");
first = 0;
}
- printf("\t\t%s: %ju\n", icmp6names[i],
+ xo_open_instance("input-histogram");
+ xo_emit("\t\t{k:name/%s}: {:count/%ju}\n",
+ icmp6names[i],
(uintmax_t)icmp6stat.icp6s_inhist[i]);
+ xo_close_instance("input-histogram");
}
+ if (!first)
+ xo_close_list("input-histogram");
#undef NELEM
- printf("\tHistogram of error messages to be generated:\n");
- p_5(icp6s_odst_unreach_noroute, "\t\t%ju no route\n");
- p_5(icp6s_odst_unreach_admin, "\t\t%ju administratively prohibited\n");
- p_5(icp6s_odst_unreach_beyondscope, "\t\t%ju beyond scope\n");
- p_5(icp6s_odst_unreach_addr, "\t\t%ju address unreachable\n");
- p_5(icp6s_odst_unreach_noport, "\t\t%ju port unreachable\n");
- p_5(icp6s_opacket_too_big, "\t\t%ju packet too big\n");
- p_5(icp6s_otime_exceed_transit, "\t\t%ju time exceed transit\n");
- p_5(icp6s_otime_exceed_reassembly, "\t\t%ju time exceed reassembly\n");
- p_5(icp6s_oparamprob_header, "\t\t%ju erroneous header field\n");
- p_5(icp6s_oparamprob_nextheader, "\t\t%ju unrecognized next header\n");
- p_5(icp6s_oparamprob_option, "\t\t%ju unrecognized option\n");
- p_5(icp6s_oredirect, "\t\t%ju redirect\n");
- p_5(icp6s_ounknown, "\t\t%ju unknown\n");
-
- p(icp6s_reflect, "\t%ju message response%s generated\n");
- p(icp6s_nd_toomanyopt, "\t%ju message%s with too many ND options\n");
- p(icp6s_nd_badopt, "\t%ju message%s with bad ND options\n");
- p(icp6s_badns, "\t%ju bad neighbor solicitation message%s\n");
- p(icp6s_badna, "\t%ju bad neighbor advertisement message%s\n");
- p(icp6s_badrs, "\t%ju bad router solicitation message%s\n");
- p(icp6s_badra, "\t%ju bad router advertisement message%s\n");
- p(icp6s_badredirect, "\t%ju bad redirect message%s\n");
- p(icp6s_pmtuchg, "\t%ju path MTU change%s\n");
+ xo_emit("\t{T:Histogram of error messages to be generated}:\n");
+ xo_open_container("errors");
+ p_5(icp6s_odst_unreach_noroute, "\t\t{:no-route/%ju} "
+ "{N:/no route}\n");
+ p_5(icp6s_odst_unreach_admin, "\t\t{:admin-prohibited/%ju} "
+ "{N:/administratively prohibited}\n");
+ p_5(icp6s_odst_unreach_beyondscope, "\t\t{:beyond-scope/%ju} "
+ "{N:/beyond scope}\n");
+ p_5(icp6s_odst_unreach_addr, "\t\t{:address-unreachable/%ju} "
+ "{N:/address unreachable}\n");
+ p_5(icp6s_odst_unreach_noport, "\t\t{:port-unreachable/%ju} "
+ "{N:/port unreachable}\n");
+ p_5(icp6s_opacket_too_big, "\t\t{:packet-too-big/%ju} "
+ "{N:/packet too big}\n");
+ p_5(icp6s_otime_exceed_transit, "\t\t{:time-exceed-transmit/%ju} "
+ "{N:/time exceed transit}\n");
+ p_5(icp6s_otime_exceed_reassembly, "\t\t{:time-exceed-reassembly/%ju} "
+ "{N:/time exceed reassembly}\n");
+ p_5(icp6s_oparamprob_header, "\t\t{:bad-header/%ju} "
+ "{N:/erroneous header field}\n");
+ p_5(icp6s_oparamprob_nextheader, "\t\t{:bad-next-header/%ju} "
+ "{N:/unrecognized next header}\n");
+ p_5(icp6s_oparamprob_option, "\t\t{:bad-option/%ju} "
+ "{N:/unrecognized option}\n");
+ p_5(icp6s_oredirect, "\t\t{:redirects/%ju} "
+ "{N:/redirect}\n");
+ p_5(icp6s_ounknown, "\t\t{:unknown/%ju} {N:unknown}\n");
+
+ p(icp6s_reflect, "\t{:reflect/%ju} "
+ "{N:/message response%s generated}\n");
+ p(icp6s_nd_toomanyopt, "\t{:too-many-nd-options/%ju} "
+ "{N:/message%s with too many ND options}\n");
+ p(icp6s_nd_badopt, "\t{:bad-nd-options/%ju} "
+ "{N:/message%s with bad ND options}\n");
+ p(icp6s_badns, "\t{:bad-neighbor-solicitation/%ju} "
+ "{N:/bad neighbor solicitation message%s}\n");
+ p(icp6s_badna, "\t{:bad-neighbor-advertisement/%ju} "
+ "{N:/bad neighbor advertisement message%s}\n");
+ p(icp6s_badrs, "\t{:bad-router-solicitation/%ju} "
+ "{N:/bad router solicitation message%s}\n");
+ p(icp6s_badra, "\t{:bad-router-advertisement/%ju} "
+ "{N:/bad router advertisement message%s}\n");
+ p(icp6s_badredirect, "\t{:bad-redirect/%ju} "
+ "{N:/bad redirect message%s}\n");
+ xo_close_container("errors");
+ p(icp6s_pmtuchg, "\t{:path-mtu-changes/%ju} {N:/path MTU change%s}\n");
#undef p
#undef p_5
+ xo_close_container(name);
}
/*
@@ -934,61 +1093,102 @@ icmp6_ifstats(char *ifname)
{
struct in6_ifreq ifr;
int s;
-#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)ifr.ifr_ifru.ifru_icmp6stat.f, plural(ifr.ifr_ifru.ifru_icmp6stat.f))
-#define p2(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)ifr.ifr_ifru.ifru_icmp6stat.f, pluralies(ifr.ifr_ifru.ifru_icmp6stat.f))
+
+#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
+ xo_emit(m, (uintmax_t)ifr.ifr_ifru.ifru_icmp6stat.f, \
+ plural(ifr.ifr_ifru.ifru_icmp6stat.f))
+#define p2(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
+ xo_emit(m, (uintmax_t)ifr.ifr_ifru.ifru_icmp6stat.f, \
+ pluralies(ifr.ifr_ifru.ifru_icmp6stat.f))
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- perror("Warning: socket(AF_INET6)");
+ xo_warn("Warning: socket(AF_INET6)");
return;
}
strcpy(ifr.ifr_name, ifname);
if (ioctl(s, SIOCGIFSTAT_ICMP6, (char *)&ifr) < 0) {
if (errno != EPFNOSUPPORT)
- perror("Warning: ioctl(SIOCGIFSTAT_ICMP6)");
+ xo_warn("Warning: ioctl(SIOCGIFSTAT_ICMP6)");
goto end;
}
- printf("icmp6 on %s:\n", ifr.ifr_name);
- p(ifs6_in_msg, "\t%ju total input message%s\n");
- p(ifs6_in_error, "\t%ju total input error message%s\n");
- p(ifs6_in_dstunreach, "\t%ju input destination unreachable error%s\n");
- p(ifs6_in_adminprohib, "\t%ju input administratively prohibited error%s\n");
- p(ifs6_in_timeexceed, "\t%ju input time exceeded error%s\n");
- p(ifs6_in_paramprob, "\t%ju input parameter problem error%s\n");
- p(ifs6_in_pkttoobig, "\t%ju input packet too big error%s\n");
- p(ifs6_in_echo, "\t%ju input echo request%s\n");
- p2(ifs6_in_echoreply, "\t%ju input echo repl%s\n");
- p(ifs6_in_routersolicit, "\t%ju input router solicitation%s\n");
- p(ifs6_in_routeradvert, "\t%ju input router advertisement%s\n");
- p(ifs6_in_neighborsolicit, "\t%ju input neighbor solicitation%s\n");
- p(ifs6_in_neighboradvert, "\t%ju input neighbor advertisement%s\n");
- p(ifs6_in_redirect, "\t%ju input redirect%s\n");
- p2(ifs6_in_mldquery, "\t%ju input MLD quer%s\n");
- p(ifs6_in_mldreport, "\t%ju input MLD report%s\n");
- p(ifs6_in_mlddone, "\t%ju input MLD done%s\n");
-
- p(ifs6_out_msg, "\t%ju total output message%s\n");
- p(ifs6_out_error, "\t%ju total output error message%s\n");
- p(ifs6_out_dstunreach, "\t%ju output destination unreachable error%s\n");
- p(ifs6_out_adminprohib, "\t%ju output administratively prohibited error%s\n");
- p(ifs6_out_timeexceed, "\t%ju output time exceeded error%s\n");
- p(ifs6_out_paramprob, "\t%ju output parameter problem error%s\n");
- p(ifs6_out_pkttoobig, "\t%ju output packet too big error%s\n");
- p(ifs6_out_echo, "\t%ju output echo request%s\n");
- p2(ifs6_out_echoreply, "\t%ju output echo repl%s\n");
- p(ifs6_out_routersolicit, "\t%ju output router solicitation%s\n");
- p(ifs6_out_routeradvert, "\t%ju output router advertisement%s\n");
- p(ifs6_out_neighborsolicit, "\t%ju output neighbor solicitation%s\n");
- p(ifs6_out_neighboradvert, "\t%ju output neighbor advertisement%s\n");
- p(ifs6_out_redirect, "\t%ju output redirect%s\n");
- p2(ifs6_out_mldquery, "\t%ju output MLD quer%s\n");
- p(ifs6_out_mldreport, "\t%ju output MLD report%s\n");
- p(ifs6_out_mlddone, "\t%ju output MLD done%s\n");
-
- end:
+ xo_emit("{T:/icmp6 on %s}:\n", ifr.ifr_name);
+
+ xo_open_instance("icmp6-interface-statistics");
+ xo_emit("{ke:name/%s}", ifr.ifr_name);
+ p(ifs6_in_msg, "\t{:received-packets/%ju} "
+ "{N:/total input message%s}\n");
+ p(ifs6_in_error, "\t{:received-errors/%ju} "
+ "{N:/total input error message%s}\n");
+ p(ifs6_in_dstunreach, "\t{:received-destination-unreachable/%ju} "
+ "{N:/input destination unreachable error%s}\n");
+ p(ifs6_in_adminprohib, "\t{:received-admin-prohibited/%ju} "
+ "{N:/input administratively prohibited error%s}\n");
+ p(ifs6_in_timeexceed, "\t{:received-time-exceeded/%ju} "
+ "{N:/input time exceeded error%s}\n");
+ p(ifs6_in_paramprob, "\t{:received-bad-parameter/%ju} "
+ "{N:/input parameter problem error%s}\n");
+ p(ifs6_in_pkttoobig, "\t{:received-packet-too-big/%ju} "
+ "{N:/input packet too big error%s}\n");
+ p(ifs6_in_echo, "\t{:received-echo-requests/%ju} "
+ "{N:/input echo request%s}\n");
+ p2(ifs6_in_echoreply, "\t{:received-echo-replies/%ju} "
+ "{N:/input echo repl%s}\n");
+ p(ifs6_in_routersolicit, "\t{:received-router-solicitation/%ju} "
+ "{N:/input router solicitation%s}\n");
+ p(ifs6_in_routeradvert, "\t{:received-router-advertisement/%ju} "
+ "{N:/input router advertisement%s}\n");
+ p(ifs6_in_neighborsolicit, "\t{:received-neighbor-solicitation/%ju} "
+ "{N:/input neighbor solicitation%s}\n");
+ p(ifs6_in_neighboradvert, "\t{:received-neighbor-advertisement/%ju} "
+ "{N:/input neighbor advertisement%s}\n");
+ p(ifs6_in_redirect, "\t{received-redirects/%ju} "
+ "{N:/input redirect%s}\n");
+ p2(ifs6_in_mldquery, "\t{:received-mld-queries/%ju} "
+ "{N:/input MLD quer%s}\n");
+ p(ifs6_in_mldreport, "\t{:received-mld-reports/%ju} "
+ "{N:/input MLD report%s}\n");
+ p(ifs6_in_mlddone, "\t{:received-mld-done/%ju} "
+ "{N:/input MLD done%s}\n");
+
+ p(ifs6_out_msg, "\t{:sent-packets/%ju} "
+ "{N:/total output message%s}\n");
+ p(ifs6_out_error, "\t{:sent-errors/%ju} "
+ "{N:/total output error message%s}\n");
+ p(ifs6_out_dstunreach, "\t{:sent-destination-unreachable/%ju} "
+ "{N:/output destination unreachable error%s}\n");
+ p(ifs6_out_adminprohib, "\t{:sent-admin-prohibited/%ju} "
+ "{N:/output administratively prohibited error%s}\n");
+ p(ifs6_out_timeexceed, "\t{:sent-time-exceeded/%ju} "
+ "{N:/output time exceeded error%s}\n");
+ p(ifs6_out_paramprob, "\t{:sent-bad-parameter/%ju} "
+ "{N:/output parameter problem error%s}\n");
+ p(ifs6_out_pkttoobig, "\t{:sent-packet-too-big/%ju} "
+ "{N:/output packet too big error%s}\n");
+ p(ifs6_out_echo, "\t{:sent-echo-requests/%ju} "
+ "{N:/output echo request%s}\n");
+ p2(ifs6_out_echoreply, "\t{:sent-echo-replies/%ju} "
+ "{N:/output echo repl%s}\n");
+ p(ifs6_out_routersolicit, "\t{:sent-router-solicitation/%ju} "
+ "{N:/output router solicitation%s}\n");
+ p(ifs6_out_routeradvert, "\t{:sent-router-advertisement/%ju} "
+ "{N:/output router advertisement%s}\n");
+ p(ifs6_out_neighborsolicit, "\t{:sent-neighbor-solicitation/%ju} "
+ "{N:/output neighbor solicitation%s}\n");
+ p(ifs6_out_neighboradvert, "\t{:sent-neighbor-advertisement/%ju} "
+ "{N:/output neighbor advertisement%s}\n");
+ p(ifs6_out_redirect, "\t{:sent-redirects/%ju} "
+ "{N:/output redirect%s}\n");
+ p2(ifs6_out_mldquery, "\t{:sent-mld-queries/%ju} "
+ "{N:/output MLD quer%s}\n");
+ p(ifs6_out_mldreport, "\t{:sent-mld-reports/%ju} "
+ "{N:/output MLD report%s}\n");
+ p(ifs6_out_mlddone, "\t{:sent-mld-dones/%ju} "
+ "{N:/output MLD done%s}\n");
+
+end:
+ xo_close_instance("icmp6-interface-statistics");
close(s);
#undef p
}
@@ -1008,7 +1208,7 @@ pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet6.pim.stats", &pim6stat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet6.pim.stats");
+ xo_warn("sysctl: net.inet6.pim.stats");
return;
}
} else {
@@ -1017,18 +1217,28 @@ pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
kread(off, &pim6stat, len);
}
- printf("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
+ xo_open_container(name);
#define p(f, m) if (pim6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)pim6stat.f, plural(pim6stat.f))
- p(pim6s_rcv_total, "\t%ju message%s received\n");
- p(pim6s_rcv_tooshort, "\t%ju message%s received with too few bytes\n");
- p(pim6s_rcv_badsum, "\t%ju message%s received with bad checksum\n");
- p(pim6s_rcv_badversion, "\t%ju message%s received with bad version\n");
- p(pim6s_rcv_registers, "\t%ju register%s received\n");
- p(pim6s_rcv_badregisters, "\t%ju bad register%s received\n");
- p(pim6s_snd_registers, "\t%ju register%s sent\n");
+ xo_emit(m, (uintmax_t)pim6stat.f, plural(pim6stat.f))
+
+ p(pim6s_rcv_total, "\t{:received-packets/%ju} "
+ "{N:/message%s received}\n");
+ p(pim6s_rcv_tooshort, "\t{:dropped-too-short/%ju} "
+ "{N:/message%s received with too few bytes}\n");
+ p(pim6s_rcv_badsum, "\t{:dropped-bad-checksum/%ju} "
+ "{N:/message%s received with bad checksum}\n");
+ p(pim6s_rcv_badversion, "\t{:dropped-bad-version/%ju} "
+ "{N:/message%s received with bad version}\n");
+ p(pim6s_rcv_registers, "\t{:received-registers/%ju} "
+ "{N:/register%s received}\n");
+ p(pim6s_rcv_badregisters, "\t{:received-bad-registers/%ju} "
+ "{N:/bad register%s received}\n");
+ p(pim6s_snd_registers, "\t{:sent-registers/%ju} "
+ "{N:/register%s sent}\n");
#undef p
+ xo_close_container(name);
}
/*
@@ -1048,33 +1258,42 @@ rip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet6.ip6.rip6stats", &rip6stat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet6.ip6.rip6stats");
+ xo_warn("sysctl: net.inet6.ip6.rip6stats");
return;
}
} else
kread_counters(off, &rip6stat, len);
- printf("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
+ xo_open_container(name);
#define p(f, m) if (rip6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)rip6stat.f, plural(rip6stat.f))
- p(rip6s_ipackets, "\t%ju message%s received\n");
- p(rip6s_isum, "\t%ju checksum calculation%s on inbound\n");
- p(rip6s_badsum, "\t%ju message%s with bad checksum\n");
- p(rip6s_nosock, "\t%ju message%s dropped due to no socket\n");
- p(rip6s_nosockmcast,
- "\t%ju multicast message%s dropped due to no socket\n");
- p(rip6s_fullsock,
- "\t%ju message%s dropped due to full socket buffers\n");
+ xo_emit(m, (uintmax_t)rip6stat.f, plural(rip6stat.f))
+
+ p(rip6s_ipackets, "\t{:received-packets/%ju} "
+ "{N:/message%s received}\n");
+ p(rip6s_isum, "\t{:input-checksum-computation/%ju} "
+ "{N:/checksum calculation%s on inbound}\n");
+ p(rip6s_badsum, "\t{:received-bad-checksum/%ju} "
+ "{N:/message%s with bad checksum}\n");
+ p(rip6s_nosock, "\t{:dropped-no-socket/%ju} "
+ "{N:/message%s dropped due to no socket}\n");
+ p(rip6s_nosockmcast, "\t{:dropped-multicast-no-socket/%ju} "
+ "{N:/multicast message%s dropped due to no socket}\n");
+ p(rip6s_fullsock, "\t{:dropped-full-socket-buffer/%ju} "
+ "{N:/message%s dropped due to full socket buffers}\n");
delivered = rip6stat.rip6s_ipackets -
rip6stat.rip6s_badsum -
rip6stat.rip6s_nosock -
rip6stat.rip6s_nosockmcast -
rip6stat.rip6s_fullsock;
if (delivered || sflag <= 1)
- printf("\t%ju delivered\n", (uintmax_t)delivered);
- p(rip6s_opackets, "\t%ju datagram%s output\n");
+ xo_emit("\t{:delivered-packets/%ju} {N:/delivered}\n",
+ (uintmax_t)delivered);
+ p(rip6s_opackets, "\t{:sent-packets/%ju} "
+ "{N:/datagram%s output}\n");
#undef p
+ xo_close_container(name);
}
/*
@@ -1092,14 +1311,18 @@ rip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
};
void
-inet6print(struct in6_addr *in6, int port, const char *proto, int numeric)
+inet6print(const char *container, struct in6_addr *in6, int port,
+ const char *proto, int numeric)
{
struct servent *sp = 0;
char line[80], *cp;
int width;
- sprintf(line, "%.*s.", Wflag ? 39 :
- (Aflag && !numeric) ? 12 : 16, inet6name(in6));
+ if (container)
+ xo_open_container(container);
+
+ sprintf(line, "%.*s.", Wflag ? 39 : (Aflag && !numeric) ? 12 : 16,
+ inet6name(in6));
cp = strchr(line, '\0');
if (!numeric && port)
GETSERVBYPORT6(port, proto, sp);
@@ -1108,7 +1331,15 @@ inet6print(struct in6_addr *in6, int port, const char *proto, int numeric)
else
sprintf(cp, "%d", ntohs((u_short)port));
width = Wflag ? 45 : Aflag ? 18 : 22;
- printf("%-*.*s ", width, width, line);
+
+ xo_emit("{d:target/%-*.*s} ", width, width, line);
+
+ int alen = cp - line - 1, plen = strlen(cp) - 1;
+ xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen,
+ plen, cp);
+
+ if (container)
+ xo_close_container(container);
}
/*
@@ -1142,7 +1373,7 @@ inet6name(struct in6_addr *in6p)
memset(&sin6, 0, sizeof(sin6));
memcpy(&sin6.sin6_addr, in6p, sizeof(*in6p));
sin6.sin6_family = AF_INET6;
- /* XXX: in6p.s6_addr[2] can contain scopeid. */
+ /* XXX: in6p.s6_addr[2] can contain scopeid. */
in6_fillscopeid(&sin6);
flags = (numeric_addr) ? NI_NUMERICHOST : 0;
error = getnameinfo((struct sockaddr *)&sin6, sizeof(sin6), hbuf,
diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c
index b4014ad..137a26c 100644
--- a/usr.bin/netstat/ipsec.c
+++ b/usr.bin/netstat/ipsec.c
@@ -107,8 +107,10 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "netstat.h"
#ifdef IPSEC
@@ -171,27 +173,39 @@ static void print_ipsecstats(const struct ipsecstat *ipsecstat);
static void
print_ipsecstats(const struct ipsecstat *ipsecstat)
{
+ xo_open_container("ipsec-statistics");
+
#define p(f, m) if (ipsecstat->f || sflag <= 1) \
- printf(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f))
- p(ips_in_polvio, "\t%ju inbound packet%s violated process "
- "security policy\n");
- p(ips_in_nomem, "\t%ju inbound packet%s failed due to "
- "insufficient memory\n");
- p(ips_in_inval, "\t%ju invalid inbound packet%s\n");
- p(ips_out_polvio, "\t%ju outbound packet%s violated process "
- "security policy\n");
- p(ips_out_nosa, "\t%ju outbound packet%s with no SA available\n");
- p(ips_out_nomem, "\t%ju outbound packet%s failed due to "
- "insufficient memory\n");
- p(ips_out_noroute, "\t%ju outbound packet%s with no route "
- "available\n");
- p(ips_out_inval, "\t%ju invalid outbound packet%s\n");
- p(ips_out_bundlesa, "\t%ju outbound packet%s with bundled SAs\n");
- p(ips_mbcoalesced, "\t%ju mbuf%s coalesced during clone\n");
- p(ips_clcoalesced, "\t%ju cluster%s coalesced during clone\n");
- p(ips_clcopied, "\t%ju cluster%s copied during clone\n");
- p(ips_mbinserted, "\t%ju mbuf%s inserted during makespace\n");
+ xo_emit(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f))
+
+ p(ips_in_polvio, "\t{:dropped-policy-violation/%ju} "
+ "{N:/inbound packet%s violated process security policy}\n");
+ p(ips_in_nomem, "\t{:dropped-no-memory/%ju} "
+ "{N:/inbound packet%s failed due to insufficient memory}\n");
+ p(ips_in_inval, "\t{:dropped-invalid/%ju} "
+ "{N:/invalid inbound packet%s}\n");
+ p(ips_out_polvio, "\t{:discarded-policy-violation/%ju} "
+ "{N:/outbound packet%s violated process security policy}\n");
+ p(ips_out_nosa, "\t{:discarded-no-sa/%ju} "
+ "{N:/outbound packet%s with no SA available}\n");
+ p(ips_out_nomem, "\t{:discarded-no-memory/%ju} "
+ "{N:/outbound packet%s failed due to insufficient memory}\n");
+ p(ips_out_noroute, "\t{:discarded-no-route/%ju} "
+ "{N:/outbound packet%s with no route available}\n");
+ p(ips_out_inval, "\t{:discarded-invalid/%ju} "
+ "{N:/invalid outbound packet%s}\n");
+ p(ips_out_bundlesa, "\t{:send-bundled-sa/%ju} "
+ "{N:/outbound packet%s with bundled SAs}\n");
+ p(ips_mbcoalesced, "\t{:mbufs-coalesced-during-clone/%ju} "
+ "{N:/mbuf%s coalesced during clone}\n");
+ p(ips_clcoalesced, "\t{:clusters-coalesced-during-clone/%ju} "
+ "{N:/cluster%s coalesced during clone}\n");
+ p(ips_clcopied, "\t{:clusters-copied-during-clone/%ju} "
+ "{N:/cluster%s copied during clone}\n");
+ p(ips_mbinserted, "\t{:mbufs-inserted/%ju} "
+ "{N:/mbuf%s inserted during makespace}\n");
#undef p
+ xo_close_container("ipsec-statistics");
}
void
@@ -201,15 +215,13 @@ ipsec_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (off == 0)
return;
- printf ("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
kread_counters(off, (char *)&ipsecstat, sizeof(ipsecstat));
print_ipsecstats(&ipsecstat);
}
-static void ipsec_hist_new(const uint64_t *hist, size_t histmax,
- const struct val2str *name, const char *title);
static void print_ahstats(const struct ahstat *ahstat);
static void print_espstats(const struct espstat *espstat);
static void print_ipcompstats(const struct ipcompstat *ipcompstat);
@@ -219,7 +231,7 @@ static void print_ipcompstats(const struct ipcompstat *ipcompstat);
*/
static void
ipsec_hist_new(const uint64_t *hist, size_t histmax,
- const struct val2str *name, const char *title)
+ const struct val2str *name, const char *title, const char *cname)
{
int first;
size_t proto;
@@ -230,54 +242,72 @@ ipsec_hist_new(const uint64_t *hist, size_t histmax,
if (hist[proto] <= 0)
continue;
if (first) {
- printf("\t%s histogram:\n", title);
+ xo_open_list(cname);
+ xo_emit("\t{T:/%s histogram}:\n", title);
first = 0;
}
+ xo_open_instance(cname);
for (p = name; p && p->str; p++) {
if (p->val == (int)proto)
break;
}
if (p && p->str) {
- printf("\t\t%s: %ju\n", p->str,
+ xo_emit("\t\t{k:name}: {:count/%ju}\n", p->str,
(uintmax_t)hist[proto]);
} else {
- printf("\t\t#%lu: %ju\n", (unsigned long)proto,
- (uintmax_t)hist[proto]);
+ xo_emit("\t\t#{k:name/%lu}: {:count/%ju}\n",
+ (unsigned long)proto, (uintmax_t)hist[proto]);
}
+ xo_close_instance(cname);
}
+ if (!first)
+ xo_close_list(cname);
}
static void
print_ahstats(const struct ahstat *ahstat)
{
-#define p(f, m) if (ahstat->f || sflag <= 1) \
- printf("\t%ju" m, (uintmax_t)ahstat->f, plural(ahstat->f))
-#define hist(f, n, t) \
- ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
-
- p(ahs_hdrops, " packet%s shorter than header shows\n");
- p(ahs_nopf, " packet%s dropped; protocol family not supported\n");
- p(ahs_notdb, " packet%s dropped; no TDB\n");
- p(ahs_badkcr, " packet%s dropped; bad KCR\n");
- p(ahs_qfull, " packet%s dropped; queue full\n");
- p(ahs_noxform, " packet%s dropped; no transform\n");
- p(ahs_wrap, " replay counter wrap%s\n");
- p(ahs_badauth, " packet%s dropped; bad authentication detected\n");
- p(ahs_badauthl, " packet%s dropped; bad authentication length\n");
- p(ahs_replay, " possible replay packet%s detected\n");
- p(ahs_input, " packet%s in\n");
- p(ahs_output, " packet%s out\n");
- p(ahs_invalid, " packet%s dropped; invalid TDB\n");
- p(ahs_ibytes, " byte%s in\n");
- p(ahs_obytes, " byte%s out\n");
- p(ahs_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p(ahs_pdrops, " packet%s blocked due to policy\n");
- p(ahs_crypto, " crypto processing failure%s\n");
- p(ahs_tunnel, " tunnel sanity check failure%s\n");
- hist(ahstat->ahs_hist, ipsec_ahnames, "AH output");
+ xo_open_container("ah-statictics");
+
+#define p(f, n, m) if (ahstat->f || sflag <= 1) \
+ xo_emit("\t{:" n "/%ju} {N:/" m "}\n", \
+ (uintmax_t)ahstat->f, plural(ahstat->f))
+#define hist(f, n, t, c) \
+ ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t), (c))
+
+ p(ahs_hdrops, "dropped-short-header",
+ "packet%s shorter than header shows");
+ p(ahs_nopf, "dropped-bad-protocol",
+ "packet%s dropped; protocol family not supported");
+ p(ahs_notdb, "dropped-no-tdb", "packet%s dropped; no TDB");
+ p(ahs_badkcr, "dropped-bad-kcr", "packet%s dropped; bad KCR");
+ p(ahs_qfull, "dropped-queue-full", "packet%s dropped; queue full");
+ p(ahs_noxform, "dropped-no-transform",
+ "packet%s dropped; no transform");
+ p(ahs_wrap, "replay-counter-wraps", "replay counter wrap%s");
+ p(ahs_badauth, "dropped-bad-auth",
+ "packet%s dropped; bad authentication detected");
+ p(ahs_badauthl, "dropped-bad-auth-level",
+ "packet%s dropped; bad authentication length");
+ p(ahs_replay, "possile-replay-detected",
+ "possible replay packet%s detected");
+ p(ahs_input, "received-packets", "packet%s in");
+ p(ahs_output, "send-packets", "packet%s out");
+ p(ahs_invalid, "dropped-bad-tdb", "packet%s dropped; invalid TDB");
+ p(ahs_ibytes, "received-bytes", "byte%s in");
+ p(ahs_obytes, "send-bytes", "byte%s out");
+ p(ahs_toobig, "dropped-too-large",
+ "packet%s dropped; larger than IP_MAXPACKET");
+ p(ahs_pdrops, "dropped-policy-violation",
+ "packet%s blocked due to policy");
+ p(ahs_crypto, "crypto-failures", "crypto processing failure%s");
+ p(ahs_tunnel, "tunnel-failures", "tunnel sanity check failure%s");
+ hist(ahstat->ahs_hist, ipsec_ahnames,
+ "AH output", "ah-output-histogram");
#undef p
#undef hist
+ xo_close_container("ah-statictics");
}
void
@@ -287,7 +317,7 @@ ah_stats(u_long off, const char *name, int family __unused, int proto __unused)
if (off == 0)
return;
- printf ("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
kread_counters(off, (char *)&ahstat, sizeof(ahstat));
print_ahstats(&ahstat);
@@ -296,35 +326,47 @@ ah_stats(u_long off, const char *name, int family __unused, int proto __unused)
static void
print_espstats(const struct espstat *espstat)
{
-#define p(f, m) if (espstat->f || sflag <= 1) \
- printf("\t%ju" m, (uintmax_t)espstat->f, plural(espstat->f))
-#define hist(f, n, t) \
- ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
-
- p(esps_hdrops, " packet%s shorter than header shows\n");
- p(esps_nopf, " packet%s dropped; protocol family not supported\n");
- p(esps_notdb, " packet%s dropped; no TDB\n");
- p(esps_badkcr, " packet%s dropped; bad KCR\n");
- p(esps_qfull, " packet%s dropped; queue full\n");
- p(esps_noxform, " packet%s dropped; no transform\n");
- p(esps_badilen, " packet%s dropped; bad ilen\n");
- p(esps_wrap, " replay counter wrap%s\n");
- p(esps_badenc, " packet%s dropped; bad encryption detected\n");
- p(esps_badauth, " packet%s dropped; bad authentication detected\n");
- p(esps_replay, " possible replay packet%s detected\n");
- p(esps_input, " packet%s in\n");
- p(esps_output, " packet%s out\n");
- p(esps_invalid, " packet%s dropped; invalid TDB\n");
- p(esps_ibytes, " byte%s in\n");
- p(esps_obytes, " byte%s out\n");
- p(esps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p(esps_pdrops, " packet%s blocked due to policy\n");
- p(esps_crypto, " crypto processing failure%s\n");
- p(esps_tunnel, " tunnel sanity check failure%s\n");
- hist(espstat->esps_hist, ipsec_espnames, "ESP output");
+ xo_open_container("esp-statictics");
+#define p(f, n, m) if (espstat->f || sflag <= 1) \
+ xo_emit("\t{:" n "/%ju} {N:/" m "}\n", \
+ (uintmax_t)espstat->f, plural(espstat->f))
+#define hist(f, n, t, c) \
+ ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t), (c));
+
+ p(esps_hdrops, "dropped-short-header",
+ "packet%s shorter than header shows");
+ p(esps_nopf, "dropped-bad-protocol",
+ "packet%s dropped; protocol family not supported");
+ p(esps_notdb, "dropped-no-tdb", "packet%s dropped; no TDB");
+ p(esps_badkcr, "dropped-bad-kcr", "packet%s dropped; bad KCR");
+ p(esps_qfull, "dropped-queue-full", "packet%s dropped; queue full");
+ p(esps_noxform, "dropped-no-transform",
+ "packet%s dropped; no transform");
+ p(esps_badilen, "dropped-bad-length", "packet%s dropped; bad ilen");
+ p(esps_wrap, "replay-counter-wraps", "replay counter wrap%s");
+ p(esps_badenc, "dropped-bad-crypto",
+ "packet%s dropped; bad encryption detected");
+ p(esps_badauth, "dropped-bad-auth",
+ "packet%s dropped; bad authentication detected");
+ p(esps_replay, "possible-replay-detected",
+ "possible replay packet%s detected");
+ p(esps_input, "received-packets", "packet%s in");
+ p(esps_output, "sent-packets", "packet%s out");
+ p(esps_invalid, "dropped-bad-tdb", "packet%s dropped; invalid TDB");
+ p(esps_ibytes, "receieve-bytes", "byte%s in");
+ p(esps_obytes, "sent-bytes", "byte%s out");
+ p(esps_toobig, "dropped-too-large",
+ "packet%s dropped; larger than IP_MAXPACKET");
+ p(esps_pdrops, "dropped-policy-violation",
+ "packet%s blocked due to policy");
+ p(esps_crypto, "crypto-failures", "crypto processing failure%s");
+ p(esps_tunnel, "tunnel-failures", "tunnel sanity check failure%s");
+ hist(espstat->esps_hist, ipsec_espnames,
+ "ESP output", "esp-output-histogram");
#undef p
#undef hist
+ xo_close_container("esp-statictics");
}
void
@@ -334,7 +376,7 @@ esp_stats(u_long off, const char *name, int family __unused, int proto __unused)
if (off == 0)
return;
- printf ("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
kread_counters(off, (char *)&espstat, sizeof(espstat));
print_espstats(&espstat);
@@ -343,32 +385,44 @@ esp_stats(u_long off, const char *name, int family __unused, int proto __unused)
static void
print_ipcompstats(const struct ipcompstat *ipcompstat)
{
-#define p(f, m) if (ipcompstat->f || sflag <= 1) \
- printf("\t%ju" m, (uintmax_t)ipcompstat->f, plural(ipcompstat->f))
-#define hist(f, n, t) \
- ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
-
- p(ipcomps_hdrops, " packet%s shorter than header shows\n");
- p(ipcomps_nopf, " packet%s dropped; protocol family not supported\n");
- p(ipcomps_notdb, " packet%s dropped; no TDB\n");
- p(ipcomps_badkcr, " packet%s dropped; bad KCR\n");
- p(ipcomps_qfull, " packet%s dropped; queue full\n");
- p(ipcomps_noxform, " packet%s dropped; no transform\n");
- p(ipcomps_wrap, " replay counter wrap%s\n");
- p(ipcomps_input, " packet%s in\n");
- p(ipcomps_output, " packet%s out\n");
- p(ipcomps_invalid, " packet%s dropped; invalid TDB\n");
- p(ipcomps_ibytes, " byte%s in\n");
- p(ipcomps_obytes, " byte%s out\n");
- p(ipcomps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p(ipcomps_pdrops, " packet%s blocked due to policy\n");
- p(ipcomps_crypto, " crypto processing failure%s\n");
- hist(ipcompstat->ipcomps_hist, ipsec_compnames, "COMP output");
- p(ipcomps_threshold, " packet%s sent uncompressed; size < compr. algo. threshold\n");
- p(ipcomps_uncompr, " packet%s sent uncompressed; compression was useless\n");
+ xo_open_container("ipcomp-statictics");
+
+#define p(f, n, m) if (ipcompstat->f || sflag <= 1) \
+ xo_emit("\t{:" n "/%ju} {N:/" m "}\n", \
+ (uintmax_t)ipcompstat->f, plural(ipcompstat->f))
+#define hist(f, n, t, c) \
+ ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t), (c));
+
+ p(ipcomps_hdrops, "dropped-short-header",
+ "packet%s shorter than header shows");
+ p(ipcomps_nopf, "dropped-bad-protocol",
+ "packet%s dropped; protocol family not supported");
+ p(ipcomps_notdb, "dropped-no-tdb", "packet%s dropped; no TDB");
+ p(ipcomps_badkcr, "dropped-bad-kcr", "packet%s dropped; bad KCR");
+ p(ipcomps_qfull, "dropped-queue-full", "packet%s dropped; queue full");
+ p(ipcomps_noxform, "dropped-no-transform",
+ "packet%s dropped; no transform");
+ p(ipcomps_wrap, "replay-counter-wraps", "replay counter wrap%s");
+ p(ipcomps_input, "receieve-packets", "packet%s in");
+ p(ipcomps_output, "sent-packets", "packet%s out");
+ p(ipcomps_invalid, "dropped-bad-tdb", "packet%s dropped; invalid TDB");
+ p(ipcomps_ibytes, "receieved-bytes", "byte%s in");
+ p(ipcomps_obytes, "sent-bytes", "byte%s out");
+ p(ipcomps_toobig, "dropped-too-large",
+ "packet%s dropped; larger than IP_MAXPACKET");
+ p(ipcomps_pdrops, "dropped-policy-violation",
+ "packet%s blocked due to policy");
+ p(ipcomps_crypto, "crypto-failure", "crypto processing failure%s");
+ hist(ipcompstat->ipcomps_hist, ipsec_compnames,
+ "COMP output", "comp-output-histogram");
+ p(ipcomps_threshold, "sent-uncompressed-small-packets",
+ "packet%s sent uncompressed; size < compr. algo. threshold");
+ p(ipcomps_uncompr, "sent-uncompressed-useless-packets",
+ "packet%s sent uncompressed; compression was useless");
#undef p
#undef hist
+ xo_close_container("ipcomp-statictics");
}
void
@@ -379,7 +433,7 @@ ipcomp_stats(u_long off, const char *name, int family __unused,
if (off == 0)
return;
- printf ("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
kread_counters(off, (char *)&ipcompstat, sizeof(ipcompstat));
print_ipcompstats(&ipcompstat);
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 8fc2b4e..acc27f7 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -65,9 +65,11 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include "netstat.h"
+#include <libxo/xo.h>
static struct nlist nl[] = {
#define N_RTSTAT 0
@@ -146,7 +148,7 @@ static struct nlist nl[] = {
{ .n_name = "_sctpstat" },
#define N_MFCTABLESIZE 37
{ .n_name = "_mfctablesize" },
-#define N_ARPSTAT 38
+#define N_ARPSTAT 38
{ .n_name = "_arpstat" },
#define N_UNP_SPHEAD 39
{ .n_name = "unp_sphead" },
@@ -271,7 +273,7 @@ struct protox *protoprotox[] = {
#endif
NULL };
-static void printproto(struct protox *, const char *);
+static void printproto(struct protox *, const char *, bool *);
static void usage(void);
static struct protox *name2protox(const char *);
static struct protox *knownname(const char *);
@@ -317,9 +319,12 @@ main(int argc, char *argv[])
int ch;
int fib = -1;
char *endptr;
+ bool first = true;
af = AF_UNSPEC;
+ argc = xo_parse_args(argc, argv);
+
while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:np:Qq:RrSTsuWw:xz"))
!= -1)
switch(ch) {
@@ -356,7 +361,7 @@ main(int argc, char *argv[])
fib = strtol(optarg, &endptr, 0);
if (*endptr != '\0' ||
(fib == 0 && (errno == EINVAL || errno == ERANGE)))
- errx(1, "%s: invalid fib", optarg);
+ xo_errx(1, "%s: invalid fib", optarg);
break;
case 'f':
if (strcmp(optarg, "inet") == 0)
@@ -379,7 +384,8 @@ main(int argc, char *argv[])
else if (strcmp(optarg, "link") == 0)
af = AF_LINK;
else {
- errx(1, "%s: unknown address family", optarg);
+ xo_errx(1, "%s: unknown address family",
+ optarg);
}
break;
case 'g':
@@ -417,9 +423,8 @@ main(int argc, char *argv[])
break;
case 'p':
if ((tp = name2protox(optarg)) == NULL) {
- errx(1,
- "%s: unknown or uninstrumented protocol",
- optarg);
+ xo_errx(1, "%s: unknown or uninstrumented "
+ "protocol", optarg);
}
pflag = 1;
break;
@@ -496,13 +501,14 @@ main(int argc, char *argv[])
if (!live)
setgid(getgid());
- if (xflag && Tflag)
- errx(1, "-x and -T are incompatible, pick one.");
+ if (xflag && Tflag)
+ xo_errx(1, "-x and -T are incompatible, pick one.");
if (Bflag) {
if (!live)
usage();
bpf_stats(interface);
+ xo_finish();
exit(0);
}
if (mflag) {
@@ -511,6 +517,7 @@ main(int argc, char *argv[])
mbpr(kvmd, nl[N_SFSTAT].n_value);
} else
mbpr(NULL, 0);
+ xo_finish();
exit(0);
}
if (Qflag) {
@@ -519,6 +526,7 @@ main(int argc, char *argv[])
netisr_stats(kvmd);
} else
netisr_stats(NULL);
+ xo_finish();
exit(0);
}
#if 0
@@ -536,19 +544,26 @@ main(int argc, char *argv[])
*/
#endif
if (iflag && !sflag) {
+ xo_open_container("statistics");
intpr(interval, NULL, af);
+ xo_close_container("statistics");
+ xo_finish();
exit(0);
}
if (rflag) {
+ xo_open_container("statistics");
if (sflag) {
rt_stats();
flowtable_stats();
} else
routepr(fib, af);
+ xo_close_container("statistics");
+ xo_finish();
exit(0);
}
if (gflag) {
+ xo_open_container("statistics");
if (sflag) {
if (af == AF_INET || af == AF_UNSPEC)
mrt_stats();
@@ -564,6 +579,8 @@ main(int argc, char *argv[])
mroute6pr();
#endif
}
+ xo_close_container("statistics");
+ xo_finish();
exit(0);
}
@@ -571,31 +588,43 @@ main(int argc, char *argv[])
kresolve_list(nl);
if (tp) {
- printproto(tp, tp->pr_name);
+ xo_open_container("statistics");
+ printproto(tp, tp->pr_name, &first);
+ if (!first)
+ xo_close_list("socket");
+ xo_close_container("statistics");
+ xo_finish();
exit(0);
}
+
+ xo_open_container("statistics");
if (af == AF_INET || af == AF_UNSPEC)
for (tp = protox; tp->pr_name; tp++)
- printproto(tp, tp->pr_name);
+ printproto(tp, tp->pr_name, &first);
#ifdef INET6
if (af == AF_INET6 || af == AF_UNSPEC)
for (tp = ip6protox; tp->pr_name; tp++)
- printproto(tp, tp->pr_name);
+ printproto(tp, tp->pr_name, &first);
#endif /*INET6*/
#ifdef IPSEC
if (af == PF_KEY || af == AF_UNSPEC)
for (tp = pfkeyprotox; tp->pr_name; tp++)
- printproto(tp, tp->pr_name);
+ printproto(tp, tp->pr_name, &first);
#endif /*IPSEC*/
#ifdef NETGRAPH
if (af == AF_NETGRAPH || af == AF_UNSPEC)
for (tp = netgraphprotox; tp->pr_name; tp++)
- printproto(tp, tp->pr_name);
+ printproto(tp, tp->pr_name, &first);
#endif /* NETGRAPH */
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value,
nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value,
- nl[N_UNP_SPHEAD].n_value);
+ nl[N_UNP_SPHEAD].n_value, &first);
+
+ if (!first)
+ xo_close_list("socket");
+ xo_close_container("statistics");
+ xo_finish();
exit(0);
}
@@ -605,24 +634,25 @@ main(int argc, char *argv[])
* is not in the namelist, ignore this one.
*/
static void
-printproto(struct protox *tp, const char *name)
+printproto(struct protox *tp, const char *name, bool *first)
{
void (*pr)(u_long, const char *, int, int);
u_long off;
+ bool doingdblocks = false;
if (sflag) {
if (iflag) {
if (tp->pr_istats)
intpr(interval, tp->pr_istats, af);
else if (pflag)
- printf("%s: no per-interface stats routine\n",
+ xo_message("%s: no per-interface stats routine",
tp->pr_name);
return;
} else {
pr = tp->pr_stats;
if (!pr) {
if (pflag)
- printf("%s: no stats routine\n",
+ xo_message("%s: no stats routine",
tp->pr_name);
return;
}
@@ -630,34 +660,39 @@ printproto(struct protox *tp, const char *name)
off = 0;
else if (tp->pr_sindex < 0) {
if (pflag)
- printf(
- "%s: stats routine doesn't work on cores\n",
- tp->pr_name);
+ xo_message("%s: stats routine doesn't "
+ "work on cores", tp->pr_name);
return;
} else
off = nl[tp->pr_sindex].n_value;
}
} else {
+ doingdblocks = true;
pr = tp->pr_cblocks;
if (!pr) {
if (pflag)
- printf("%s: no PCB routine\n", tp->pr_name);
+ xo_message("%s: no PCB routine", tp->pr_name);
return;
}
if (tp->pr_usesysctl && live)
off = 0;
else if (tp->pr_index < 0) {
if (pflag)
- printf(
- "%s: PCB routine doesn't work on cores\n",
- tp->pr_name);
+ xo_message("%s: PCB routine doesn't work on "
+ "cores", tp->pr_name);
return;
} else
off = nl[tp->pr_index].n_value;
}
if (pr != NULL && (off || (live && tp->pr_usesysctl) ||
- af != AF_UNSPEC))
+ af != AF_UNSPEC)) {
+ if (doingdblocks && *first) {
+ xo_open_list("socket");
+ *first = false;
+ }
+
(*pr)(off, name, af, tp->pr_protocol);
+ }
}
static int
@@ -672,7 +707,7 @@ kvmd_init(void)
setgid(getgid());
if (kvmd == NULL) {
- warnx("kvm not available: %s", errbuf);
+ xo_warnx("kvm not available: %s", errbuf);
return (-1);
}
@@ -694,10 +729,10 @@ kresolve_list(struct nlist *_nl)
if (kvm_nlist(kvmd, _nl) < 0) {
if (nlistf)
- errx(1, "%s: kvm_nlist: %s", nlistf,
- kvm_geterr(kvmd));
+ xo_errx(1, "%s: kvm_nlist: %s", nlistf,
+ kvm_geterr(kvmd));
else
- errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
+ xo_errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
}
return (0);
@@ -716,7 +751,7 @@ kread(u_long addr, void *buf, size_t size)
if (!buf)
return (0);
if (kvm_read(kvmd, addr, buf, size) != (ssize_t)size) {
- warnx("%s", kvm_geterr(kvmd));
+ xo_warnx("%s", kvm_geterr(kvmd));
return (-1);
}
return (0);
@@ -823,7 +858,7 @@ name2protox(const char *name)
static void
usage(void)
{
- (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
+ (void)xo_error("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: netstat [-46AaLnRSTWx] [-f protocol_family | -p protocol]\n"
" [-M core] [-N system]",
" netstat -i | -I interface [-46abdhnW] [-f address_family]\n"
@@ -842,5 +877,6 @@ usage(void)
" netstat -g [-46W] [-f address_family] [-M core] [-N system]",
" netstat -gs [-46s] [-f address_family] [-M core] [-N system]",
" netstat -Q");
+ xo_finish();
exit(1);
}
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index ebd843f..26b7095 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -56,7 +56,9 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
+#include <libxo/xo.h>
#include "netstat.h"
/*
@@ -88,7 +90,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtlp = memstat_mtl_alloc();
if (mtlp == NULL) {
- warn("memstat_mtl_alloc");
+ xo_warn("memstat_mtl_alloc");
return;
}
@@ -98,7 +100,7 @@ mbpr(void *kvmd, u_long mbaddr)
*/
if (live) {
if (memstat_sysctl_all(mtlp, 0) < 0) {
- warnx("memstat_sysctl_all: %s",
+ xo_warnx("memstat_sysctl_all: %s",
memstat_strerror(memstat_mtl_geterror(mtlp)));
goto out;
}
@@ -106,10 +108,10 @@ mbpr(void *kvmd, u_long mbaddr)
if (memstat_kvm_all(mtlp, kvmd) < 0) {
error = memstat_mtl_geterror(mtlp);
if (error == MEMSTAT_ERROR_KVM)
- warnx("memstat_kvm_all: %s",
+ xo_warnx("memstat_kvm_all: %s",
kvm_geterr(kvmd));
else
- warnx("memstat_kvm_all: %s",
+ xo_warnx("memstat_kvm_all: %s",
memstat_strerror(error));
goto out;
}
@@ -117,7 +119,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: zone %s not found", MBUF_MEM_NAME);
+ xo_warnx("memstat_mtl_find: zone %s not found", MBUF_MEM_NAME);
goto out;
}
mbuf_count = memstat_get_count(mtp);
@@ -129,7 +131,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_PACKET_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: zone %s not found",
+ xo_warnx("memstat_mtl_find: zone %s not found",
MBUF_PACKET_MEM_NAME);
goto out;
}
@@ -141,7 +143,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_CLUSTER_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: zone %s not found",
+ xo_warnx("memstat_mtl_find: zone %s not found",
MBUF_CLUSTER_MEM_NAME);
goto out;
}
@@ -154,7 +156,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_MALLOC, MBUF_TAG_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: malloc type %s not found",
+ xo_warnx("memstat_mtl_find: malloc type %s not found",
MBUF_TAG_MEM_NAME);
goto out;
}
@@ -162,7 +164,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBOP_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: zone %s not found",
+ xo_warnx("memstat_mtl_find: zone %s not found",
MBUF_JUMBOP_MEM_NAME);
goto out;
}
@@ -175,7 +177,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO9_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: zone %s not found",
+ xo_warnx("memstat_mtl_find: zone %s not found",
MBUF_JUMBO9_MEM_NAME);
goto out;
}
@@ -188,7 +190,7 @@ mbpr(void *kvmd, u_long mbaddr)
mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO16_MEM_NAME);
if (mtp == NULL) {
- warnx("memstat_mtl_find: zone %s not found",
+ xo_warnx("memstat_mtl_find: zone %s not found",
MBUF_JUMBO16_MEM_NAME);
goto out;
}
@@ -199,36 +201,44 @@ mbpr(void *kvmd, u_long mbaddr)
jumbo16_sleeps = memstat_get_sleeps(mtp);
jumbo16_size = memstat_get_size(mtp);
- printf("%ju/%ju/%ju mbufs in use (current/cache/total)\n",
+ xo_open_container("mbuf-statistics");
+
+ xo_emit("{:mbuf-current/%ju}/{:mbuf-cache/%ju}/{:mbuf-total/%ju} "
+ "{N:mbufs in use (current\\/cache\\/total)}\n",
mbuf_count + packet_count, mbuf_free + packet_free,
mbuf_count + packet_count + mbuf_free + packet_free);
- printf("%ju/%ju/%ju/%ju mbuf clusters in use "
- "(current/cache/total/max)\n",
+ xo_emit("{:cluster-current/%ju}/{:cluster-cache/%ju}/"
+ "{:cluster-total/%ju}/{:cluster-max/%ju} "
+ "{N:mbuf clusters in use (current\\/cache\\/total\\/max)}\n",
cluster_count - packet_free, cluster_free + packet_free,
cluster_count + cluster_free, cluster_limit);
- printf("%ju/%ju mbuf+clusters out of packet secondary zone in use "
- "(current/cache)\n",
+ xo_emit("{:packet-count/%ju}/{:packet-free/%ju} "
+ "{N:mbuf+clusters out of packet secondary zone in use "
+ "(current\\/cache)}\n",
packet_count, packet_free);
- printf("%ju/%ju/%ju/%ju %juk (page size) jumbo clusters in use "
- "(current/cache/total/max)\n",
+ xo_emit("{:jumbo-count/%ju}/{:jumbo-cache/%ju}/{:jumbo-total/%ju}/"
+ "{:jumbo-max/%ju} {:jumbo-page-size/%ju}{U:k} {N:(page size)} "
+ "{N:jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
jumbop_count, jumbop_free, jumbop_count + jumbop_free,
jumbop_limit, jumbop_size / 1024);
- printf("%ju/%ju/%ju/%ju 9k jumbo clusters in use "
- "(current/cache/total/max)\n",
+ xo_emit("{:jumbo9-count/%ju}/{:jumbo9-cache/%ju}/"
+ "{:jumbo9-total/%ju}/{:jumbo9-max/%ju} "
+ "{N:9k jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
jumbo9_count, jumbo9_free, jumbo9_count + jumbo9_free,
jumbo9_limit);
- printf("%ju/%ju/%ju/%ju 16k jumbo clusters in use "
- "(current/cache/total/max)\n",
+ xo_emit("{:jumbo16-count/%ju}/{:jumbo16-cache/%ju}/"
+ "{:jumbo16-total/%ju}/{:jumbo16-limit/%ju} "
+ "{N:16k jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
jumbo16_count, jumbo16_free, jumbo16_count + jumbo16_free,
jumbo16_limit);
#if 0
- printf("%ju mbuf tags in use\n", tag_count);
+ xo_emit("{:tag-count/%ju} {N:mbuf tags in use}\n", tag_count);
#endif
/*-
@@ -276,23 +286,29 @@ mbpr(void *kvmd, u_long mbaddr)
*/
bytes_total = bytes_inuse + bytes_incache;
- printf("%juK/%juK/%juK bytes allocated to network "
- "(current/cache/total)\n", bytes_inuse / 1024,
- bytes_incache / 1024, bytes_total / 1024);
+ xo_emit("{:bytes-in-use/%ju}{U:K}/{:bytes-in-cache/%ju}{U:K}/"
+ "{:bytes-total/%ju}{U:K} "
+ "{N:bytes allocated to network (current\\/cache\\/total)}\n",
+ bytes_inuse / 1024, bytes_incache / 1024, bytes_total / 1024);
- printf("%ju/%ju/%ju requests for mbufs denied (mbufs/clusters/"
- "mbuf+clusters)\n", mbuf_failures, cluster_failures,
- packet_failures);
- printf("%ju/%ju/%ju requests for mbufs delayed (mbufs/clusters/"
- "mbuf+clusters)\n", mbuf_sleeps, cluster_sleeps,
- packet_sleeps);
+ xo_emit("{:mbuf-failures/%ju}/{:cluster-failures/%ju}/"
+ "{:packet-failures/%ju} {N:requests for mbufs denied "
+ "(mbufs\\/clusters\\/mbuf+clusters)}\n",
+ mbuf_failures, cluster_failures, packet_failures);
+ xo_emit("{:mbuf-sleeps/%ju}/{:cluster-sleeps/%ju}/{:packet-sleeps/%ju} "
+ "{N:requests for mbufs delayed "
+ "(mbufs\\/clusters\\/mbuf+clusters)}\n",
+ mbuf_sleeps, cluster_sleeps, packet_sleeps);
- printf("%ju/%ju/%ju requests for jumbo clusters delayed "
- "(%juk/9k/16k)\n", jumbop_sleeps, jumbo9_sleeps,
- jumbo16_sleeps, jumbop_size / 1024);
- printf("%ju/%ju/%ju requests for jumbo clusters denied "
- "(%juk/9k/16k)\n", jumbop_failures, jumbo9_failures,
- jumbo16_failures, jumbop_size / 1024);
+ xo_emit("{:jumbop-sleeps/%ju}/{:jumbo9-sleeps/%ju}/"
+ "{:jumbo16-sleeps/%ju} {N:/requests for jumbo clusters delayed "
+ "(%juk\\/9k\\/16k)}\n",
+ jumbop_sleeps, jumbo9_sleeps, jumbo16_sleeps, jumbop_size / 1024);
+ xo_emit("{:jumbop-failures/%ju}/{:jumbo9-failures/%ju}/"
+ "{:jumbo16-failures/%ju} {N:/requests for jumbo clusters denied "
+ "(%juk\\/9k\\/16k)}\n",
+ jumbop_failures, jumbo9_failures, jumbo16_failures,
+ jumbop_size / 1024);
if (live) {
mlen = sizeof(nsfbufs);
@@ -302,23 +318,27 @@ mbpr(void *kvmd, u_long mbaddr)
&mlen, NULL, 0) &&
!sysctlbyname("kern.ipc.nsfbufspeak", &nsfbufspeak,
&mlen, NULL, 0))
- printf("%d/%d/%d sfbufs in use (current/peak/max)\n",
+ xo_emit("{:nsfbufs-current/%d}/{:nsfbufs-peak/%d}/"
+ "{:nsfbufs/%d} "
+ "{N:sfbufs in use (current\\/peak\\/max)}\n",
nsfbufsused, nsfbufspeak, nsfbufs);
mlen = sizeof(sfstat);
if (sysctlbyname("kern.ipc.sfstat", &sfstat, &mlen, NULL, 0)) {
- warn("kern.ipc.sfstat");
+ xo_warn("kern.ipc.sfstat");
goto out;
}
} else {
if (kread_counters(mbaddr, (char *)&sfstat, sizeof sfstat) != 0)
goto out;
}
- printf("%ju requests for sfbufs denied\n",
+ xo_emit("{:sfbufs-alloc-failed/%ju} {N:requests for sfbufs denied}\n",
(uintmax_t)sfstat.sf_allocfail);
- printf("%ju requests for sfbufs delayed\n",
+ xo_emit("{:sfbufs-alloc-wait/%ju} {N:requests for sfbufs delayed}\n",
(uintmax_t)sfstat.sf_allocwait);
- printf("%ju requests for I/O initiated by sendfile\n",
+ xo_emit("{:sfbufs-io-count/%ju} "
+ "{N:requests for I\\/O initiated by sendfile}\n",
(uintmax_t)sfstat.sf_iocnt);
out:
+ xo_close_container("mbuf-statistics");
memstat_mtl_free(mtlp);
}
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 3ec716d..37c8868 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -69,6 +69,8 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
+#include <libxo/xo.h>
#include "netstat.h"
/*
@@ -92,77 +94,85 @@ static void print_mfc(struct mfc *, int, int *);
static void
print_bw_meter(struct bw_meter *bw_meter, int *banner_printed)
{
- char s0[256], s1[256], s2[256], s3[256];
+ char s1[256], s2[256], s3[256];
struct timeval now, end, delta;
gettimeofday(&now, NULL);
if (! *banner_printed) {
- printf(" Bandwidth Meters\n");
- printf(" %-30s", "Measured(Start|Packets|Bytes)");
- printf(" %s", "Type");
- printf(" %-30s", "Thresh(Interval|Packets|Bytes)");
- printf(" Remain");
- printf("\n");
+ xo_open_list("bandwidth-meter");
+ xo_emit(" {T:Bandwidth Meters}\n");
+ xo_emit(" {T:/%-30s}", "Measured(Start|Packets|Bytes)");
+ xo_emit(" {T:/%s}", "Type");
+ xo_emit(" {T:/%-30s}", "Thresh(Interval|Packets|Bytes)");
+ xo_emit(" {T:Remain}");
+ xo_emit("\n");
*banner_printed = 1;
}
+ xo_open_instance("bandwidth-meter");
+
/* The measured values */
- if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS)
+ if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) {
sprintf(s1, "%ju", (uintmax_t)bw_meter->bm_measured.b_packets);
- else
+ xo_emit("{e:measured-packets/%ju}",
+ (uintmax_t)bw_meter->bm_measured.b_packets);
+ } else
sprintf(s1, "?");
- if (bw_meter->bm_flags & BW_METER_UNIT_BYTES)
+ if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) {
sprintf(s2, "%ju", (uintmax_t)bw_meter->bm_measured.b_bytes);
- else
+ xo_emit("{e:measured-bytes/%ju}",
+ (uintmax_t)bw_meter->bm_measured.b_bytes);
+ } else
sprintf(s2, "?");
- sprintf(s0, "%lu.%lu|%s|%s",
- (u_long)bw_meter->bm_start_time.tv_sec,
- (u_long)bw_meter->bm_start_time.tv_usec,
- s1, s2);
- printf(" %-30s", s0);
+ xo_emit(" {[:-30}{:start-time/%lu.%06lu}|{q:measured-packets/%s}"
+ "|{q:measured-bytes%s}{]:}",
+ (u_long)bw_meter->bm_start_time.tv_sec,
+ (u_long)bw_meter->bm_start_time.tv_usec, s1, s2);
/* The type of entry */
- sprintf(s0, "%s", "?");
- if (bw_meter->bm_flags & BW_METER_GEQ)
- sprintf(s0, "%s", ">=");
- else if (bw_meter->bm_flags & BW_METER_LEQ)
- sprintf(s0, "%s", "<=");
- printf(" %-3s", s0);
+ xo_emit(" {t:type/%-3s}", (bw_meter->bm_flags & BW_METER_GEQ) ? ">=" :
+ (bw_meter->bm_flags & BW_METER_LEQ) ? "<=" : "?");
/* The threshold values */
- if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS)
+ if (bw_meter->bm_flags & BW_METER_UNIT_PACKETS) {
sprintf(s1, "%ju", (uintmax_t)bw_meter->bm_threshold.b_packets);
- else
+ xo_emit("{e:threshold-packets/%ju}",
+ (uintmax_t)bw_meter->bm_threshold.b_packets);
+ } else
sprintf(s1, "?");
- if (bw_meter->bm_flags & BW_METER_UNIT_BYTES)
+ if (bw_meter->bm_flags & BW_METER_UNIT_BYTES) {
sprintf(s2, "%ju", (uintmax_t)bw_meter->bm_threshold.b_bytes);
- else
+ xo_emit("{e:threshold-bytes/%ju}",
+ (uintmax_t)bw_meter->bm_threshold.b_bytes);
+ } else
sprintf(s2, "?");
- sprintf(s0, "%lu.%lu|%s|%s",
- (u_long)bw_meter->bm_threshold.b_time.tv_sec,
- (u_long)bw_meter->bm_threshold.b_time.tv_usec,
- s1, s2);
- printf(" %-30s", s0);
+
+ xo_emit(" {[:-30}{:threshold-time/%lu.%06lu}|{q:threshold-packets/%s}"
+ "|{q:threshold-bytes%s}{]:}",
+ (u_long)bw_meter->bm_threshold.b_time.tv_sec,
+ (u_long)bw_meter->bm_threshold.b_time.tv_usec, s1, s2);
/* Remaining time */
timeradd(&bw_meter->bm_start_time,
&bw_meter->bm_threshold.b_time, &end);
if (timercmp(&now, &end, <=)) {
timersub(&end, &now, &delta);
- sprintf(s3, "%lu.%lu",
+ sprintf(s3, "%lu.%06lu",
(u_long)delta.tv_sec,
(u_long)delta.tv_usec);
} else {
/* Negative time */
timersub(&now, &end, &delta);
- sprintf(s3, "-%lu.%lu",
+ sprintf(s3, "-%lu.06%lu",
(u_long)delta.tv_sec,
(u_long)delta.tv_usec);
}
- printf(" %s", s3);
+ xo_emit(" {:remaining-time/%s}", s3);
- printf("\n");
+ xo_open_instance("bandwidth-meter");
+
+ xo_emit("\n");
}
static void
@@ -176,21 +186,29 @@ print_mfc(struct mfc *m, int maxvif, int *banner_printed)
bw_banner_printed = 0;
if (! *banner_printed) {
- printf("\nIPv4 Multicast Forwarding Table\n"
- " Origin Group "
- " Packets In-Vif Out-Vifs:Ttls\n");
+ xo_open_list("multicast-forwarding-entry");
+ xo_emit("\n{T:IPv4 Multicast Forwarding Table}\n"
+ " {T:Origin} {T:Group} "
+ " {T:Packets In-Vif} {T:Out-Vifs:Ttls}\n");
*banner_printed = 1;
}
- printf(" %-15.15s", routename(m->mfc_origin.s_addr));
- printf(" %-15.15s", routename(m->mfc_mcastgrp.s_addr));
- printf(" %9lu", m->mfc_pkt_cnt);
- printf(" %3d ", m->mfc_parent);
+ xo_emit(" {:origin-address/%-15.15s}", routename(m->mfc_origin.s_addr));
+ xo_emit(" {:group-address/%-15.15s}",
+ routename(m->mfc_mcastgrp.s_addr));
+ xo_emit(" {:sent-packets/%9lu}", m->mfc_pkt_cnt);
+ xo_emit(" {:parent/%3d} ", m->mfc_parent);
+ xo_open_list("vif-ttl");
for (vifi = 0; vifi <= maxvif; vifi++) {
- if (m->mfc_ttls[vifi] > 0)
- printf(" %u:%u", vifi, m->mfc_ttls[vifi]);
+ if (m->mfc_ttls[vifi] > 0) {
+ xo_open_instance("vif-ttl");
+ xo_emit(" {k:vif/%u}:{:ttl/%u}", vifi,
+ m->mfc_ttls[vifi]);
+ xo_close_instance("vif-ttl");
+ }
}
- printf("\n");
+ xo_close_list("vif-ttl");
+ xo_emit("\n");
/*
* XXX We break the rules and try to use KVM to read the
@@ -205,6 +223,8 @@ print_mfc(struct mfc *m, int maxvif, int *banner_printed)
print_bw_meter(&bw_meter, &bw_banner_printed);
bwm = bw_meter.bm_mfc_next;
}
+ if (banner_printed)
+ xo_close_list("bandwidth-meter");
}
void
@@ -242,7 +262,7 @@ mroutepr()
if (live) {
if (sysctlbyname("net.inet.ip.viftable", viftable, &len, NULL,
0) < 0) {
- warn("sysctl: net.inet.ip.viftable");
+ xo_warn("sysctl: net.inet.ip.viftable");
return;
}
} else {
@@ -252,7 +272,7 @@ mroutepr()
pviftbl = mrl[N_VIFTABLE].n_value;
if (pmfchashtbl == 0 || pmfctablesize == 0 || pviftbl == 0) {
- fprintf(stderr, "No IPv4 MROUTING kernel support.\n");
+ xo_warnx("No IPv4 MROUTING kernel support.");
return;
}
@@ -266,23 +286,29 @@ mroutepr()
maxvif = vifi;
if (!banner_printed) {
- printf("\nIPv4 Virtual Interface Table\n"
- " Vif Thresh Local-Address "
- "Remote-Address Pkts-In Pkts-Out\n");
+ xo_emit("\n{T:IPv4 Virtual Interface Table\n"
+ " Vif Thresh Local-Address "
+ "Remote-Address Pkts-In Pkts-Out}\n");
banner_printed = 1;
+ xo_open_list("vif");
}
- printf(" %2u %6u %-15.15s",
+ xo_open_instance("vif");
+ xo_emit(" {:vif/%2u} {:threshold/%6u} {:route/%-15.15s}",
/* opposite math of add_vif() */
vifi, v->v_threshold,
routename(v->v_lcl_addr.s_addr));
- printf(" %-15.15s", (v->v_flags & VIFF_TUNNEL) ?
+ xo_emit(" {:source/%-15.15s}", (v->v_flags & VIFF_TUNNEL) ?
routename(v->v_rmt_addr.s_addr) : "");
- printf(" %9lu %9lu\n", v->v_pkt_in, v->v_pkt_out);
+ xo_emit(" {:received-packets/%9lu} {:sent-packets/%9lu}\n",
+ v->v_pkt_in, v->v_pkt_out);
+ xo_close_instance("vif");
}
- if (!banner_printed)
- printf("\nIPv4 Virtual Interface Table is empty\n");
+ if (banner_printed)
+ xo_close_list("vif");
+ else
+ xo_emit("\n{T:IPv4 Virtual Interface Table is empty}\n");
banner_printed = 0;
@@ -302,19 +328,19 @@ mroutepr()
len = 0;
if (sysctlbyname("net.inet.ip.mfctable", NULL, &len, NULL,
0) < 0) {
- warn("sysctl: net.inet.ip.mfctable");
+ xo_warn("sysctl: net.inet.ip.mfctable");
return;
}
mfctable = malloc(len);
if (mfctable == NULL) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return;
}
if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL,
0) < 0) {
free(mfctable);
- warn("sysctl: net.inet.ip.mfctable");
+ xo_warn("sysctl: net.inet.ip.mfctable");
return;
}
@@ -323,8 +349,10 @@ mroutepr()
print_mfc(m++, maxvif, &banner_printed);
len -= sizeof(*m);
}
+ if (banner_printed)
+ xo_close_list("multicast-forwarding-entry");
if (len != 0)
- warnx("print_mfc: %lu trailing bytes", (u_long)len);
+ xo_warnx("print_mfc: %lu trailing bytes", (u_long)len);
free(mfctable);
} else {
@@ -336,14 +364,14 @@ mroutepr()
error = kread(pmfctablesize, (char *)&mfctablesize,
sizeof(u_long));
if (error) {
- warn("kread: mfctablesize");
+ xo_warn("kread: mfctablesize");
return;
}
len = sizeof(*mfchashtbl) * mfctablesize;
mfchashtbl = malloc(len);
if (mfchashtbl == NULL) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return;
}
kread(pmfchashtbl, (char *)&mfchashtbl, len);
@@ -354,14 +382,16 @@ mroutepr()
print_mfc(m, maxvif, &banner_printed);
}
}
+ if (banner_printed)
+ xo_close_list("multicast-forwarding-entry");
free(mfchashtbl);
}
if (!banner_printed)
- printf("\nIPv4 Multicast Forwarding Table is empty\n");
+ xo_emit("\n{T:IPv4 Multicast Forwarding Table is empty}\n");
- printf("\n");
+ xo_emit("\n");
numeric_addr = saved_numeric_addr;
}
@@ -383,33 +413,48 @@ mrt_stats()
if (live) {
if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL,
0) < 0) {
- warn("sysctl: net.inet.ip.mrtstat failed.");
+ xo_warn("sysctl: net.inet.ip.mrtstat failed.");
return;
}
} else
kread_counters(mstaddr, &mrtstat, len);
- printf("IPv4 multicast forwarding:\n");
+ xo_emit("{T:IPv4 multicast forwarding}:\n");
#define p(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
+ xo_emit(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
#define p2(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
-
- p(mrts_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");
- p2(mrts_mfc_misses, "\t%ju multicast forwarding cache miss%s\n");
- p(mrts_upcalls, "\t%ju upcall%s to multicast routing daemon\n");
- p(mrts_upq_ovflw, "\t%ju upcall queue overflow%s\n");
+ xo_emit(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
+
+ xo_open_container("multicast-statistics");
+
+ p(mrts_mfc_lookups, "\t{:cache-lookups/%ju} "
+ "{N:/multicast forwarding cache lookup%s}\n");
+ p2(mrts_mfc_misses, "\t{:cache-misses/%ju} "
+ "{N:/multicast forwarding cache miss%s}\n");
+ p(mrts_upcalls, "\t{:upcalls-total/%ju} "
+ "{N:/upcall%s to multicast routing daemon}\n");
+ p(mrts_upq_ovflw, "\t{:upcall-overflows/%ju} "
+ "{N:/upcall queue overflow%s}\n");
p(mrts_upq_sockfull,
- "\t%ju upcall%s dropped due to full socket buffer\n");
- p(mrts_cache_cleanups, "\t%ju cache cleanup%s\n");
- p(mrts_no_route, "\t%ju datagram%s with no route for origin\n");
- p(mrts_bad_tunnel, "\t%ju datagram%s arrived with bad tunneling\n");
- p(mrts_cant_tunnel, "\t%ju datagram%s could not be tunneled\n");
- p(mrts_wrong_if, "\t%ju datagram%s arrived on wrong interface\n");
- p(mrts_drop_sel, "\t%ju datagram%s selectively dropped\n");
- p(mrts_q_overflow, "\t%ju datagram%s dropped due to queue overflow\n");
- p(mrts_pkt2large, "\t%ju datagram%s dropped for being too large\n");
+ "\t{:upcalls-dropped-full-buffer/%ju} "
+ "{N:/upcall%s dropped due to full socket buffer}\n");
+ p(mrts_cache_cleanups, "\t{:cache-cleanups/%ju} "
+ "{N:/cache cleanup%s}\n");
+ p(mrts_no_route, "\t{:dropped-no-origin/%ju} "
+ "{N:/datagram%s with no route for origin}\n");
+ p(mrts_bad_tunnel, "\t{:dropped-bad-tunnel/%ju} "
+ "{N:/datagram%s arrived with bad tunneling}\n");
+ p(mrts_cant_tunnel, "\t{:dropped-could-not-tunnel/%ju} "
+ "{N:/datagram%s could not be tunneled}\n");
+ p(mrts_wrong_if, "\t{:dropped-wrong-incoming-interface/%ju} "
+ "{N:/datagram%s arrived on wrong interface}\n");
+ p(mrts_drop_sel, "\t{:dropped-selectively/%ju} "
+ "{N:/datagram%s selectively dropped}\n");
+ p(mrts_q_overflow, "\t{:dropped-queue-overflow/%ju} "
+ "{N:/datagram%s dropped due to queue overflow}\n");
+ p(mrts_pkt2large, "\t{:dropped-too-large/%ju} "
+ "{N:/datagram%s dropped for being too large}\n");
#undef p2
#undef p
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
index ac31f5e..f00b119 100644
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -89,6 +89,8 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
+#include <libxo/xo.h>
#define KERNEL 1
#include <netinet6/ip6_mroute.h>
@@ -143,7 +145,7 @@ mroute6pr()
if (live) {
if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
NULL, 0) < 0) {
- warn("sysctl: net.inet6.ip6.mif6table");
+ xo_warn("sysctl: net.inet6.ip6.mif6table");
return;
}
} else
@@ -165,28 +167,33 @@ mroute6pr()
maxmif = mifi;
if (!banner_printed) {
- printf("\nIPv6 Multicast Interface Table\n"
- " Mif Rate PhyIF "
- "Pkts-In Pkts-Out\n");
+ xo_open_list("multicast-interface");
+ xo_emit("\n{T:IPv6 Multicast Interface Table}\n"
+ "{T: Mif Rate PhyIF Pkts-In Pkts-Out}\n");
banner_printed = 1;
}
- printf(" %2u %4d",
- mifi, mifp->m6_rate_limit);
- printf(" %5s", (mifp->m6_flags & MIFF_REGISTER) ?
- "reg0" : if_indextoname(ifnet.if_index, ifname));
+ xo_open_instance("multicast-interface");
+ xo_emit(" {:mif/%2u} {:rate-limit/%4d}",
+ mifi, mifp->m6_rate_limit);
+ xo_emit(" {:ifname/%5s}", (mifp->m6_flags & MIFF_REGISTER) ?
+ "reg0" : if_indextoname(ifnet.if_index, ifname));
- printf(" %9ju %9ju\n", (uintmax_t)mifp->m6_pkt_in,
+ xo_emit(" {:received-packets/%9ju} {:sent-packets/%9ju}\n",
+ (uintmax_t)mifp->m6_pkt_in,
(uintmax_t)mifp->m6_pkt_out);
+ xo_close_instance("multicast-interface");
}
- if (!banner_printed)
- printf("\nIPv6 Multicast Interface Table is empty\n");
+ if (banner_printed)
+ xo_open_list("multicast-interface");
+ else
+ xo_emit("\n{T:IPv6 Multicast Interface Table is empty}\n");
len = sizeof(mf6ctable);
if (live) {
if (sysctlbyname("net.inet6.ip6.mf6ctable", mf6ctable, &len,
NULL, 0) < 0) {
- warn("sysctl: net.inet6.ip6.mf6ctable");
+ xo_warn("sysctl: net.inet6.ip6.mf6ctable");
return;
}
} else
@@ -199,19 +206,24 @@ mroute6pr()
while(mfcp) {
kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
if (!banner_printed) {
- printf ("\nIPv6 Multicast Forwarding Cache\n");
- printf(" %-*.*s %-*.*s %s",
- WID_ORG, WID_ORG, "Origin",
- WID_GRP, WID_GRP, "Group",
- " Packets Waits In-Mif Out-Mifs\n");
+ xo_open_list("multicast-forwarding-cache");
+ xo_emit("\n"
+ "{T:IPv6 Multicast Forwarding Cache}\n");
+ xo_emit(" {T:%-*.*s} {T:%-*.*s} {T:%s}",
+ WID_ORG, WID_ORG, "Origin",
+ WID_GRP, WID_GRP, "Group",
+ " Packets Waits In-Mif Out-Mifs\n");
banner_printed = 1;
}
- printf(" %-*.*s", WID_ORG, WID_ORG,
- routename6(&mfc.mf6c_origin));
- printf(" %-*.*s", WID_GRP, WID_GRP,
- routename6(&mfc.mf6c_mcastgrp));
- printf(" %9ju", (uintmax_t)mfc.mf6c_pkt_cnt);
+ xo_open_instance("multicast-forwarding-cache");
+
+ xo_emit(" {:origin/%-*.*s}", WID_ORG, WID_ORG,
+ routename6(&mfc.mf6c_origin));
+ xo_emit(" {:group/%-*.*s}", WID_GRP, WID_GRP,
+ routename6(&mfc.mf6c_mcastgrp));
+ xo_emit(" {:total-packets/%9ju}",
+ (uintmax_t)mfc.mf6c_pkt_cnt);
for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {
waitings++;
@@ -219,25 +231,30 @@ mroute6pr()
kread((u_long)rtep, (char *)&rte, sizeof(rte));
rtep = rte.next;
}
- printf(" %3ld", waitings);
+ xo_emit(" {:waitings/%3ld}", waitings);
if (mfc.mf6c_parent == MF6C_INCOMPLETE_PARENT)
- printf(" --- ");
+ xo_emit(" --- ");
else
- printf(" %3d ", mfc.mf6c_parent);
+ xo_emit(" {:parent/%3d} ", mfc.mf6c_parent);
+ xo_open_list("mif");
for (mifi = 0; mifi <= maxmif; mifi++) {
if (IF_ISSET(mifi, &mfc.mf6c_ifset))
- printf(" %u", mifi);
+ xo_emit(" {l:%u}", mifi);
}
- printf("\n");
+ xo_close_list("mif");
+ xo_emit("\n");
mfcp = mfc.mf6c_next;
+ xo_close_instance("multicast-forwarding-cache");
}
}
- if (!banner_printed)
- printf("\nIPv6 Multicast Forwarding Table is empty\n");
+ if (banner_printed)
+ xo_close_list("multicast-forwarding-cache");
+ else
+ xo_emit("\n{T:IPv6 Multicast Forwarding Table is empty}\n");
- printf("\n");
+ xo_emit("\n");
numeric_addr = saved_numeric_addr;
}
@@ -259,36 +276,49 @@ mrt6_stats()
if (live) {
if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
NULL, 0) < 0) {
- warn("sysctl: net.inet6.ip6.mrt6stat");
+ xo_warn("sysctl: net.inet6.ip6.mrt6stat");
return;
}
} else
kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
- printf("IPv6 multicast forwarding:\n");
+ xo_open_container("multicast-statistics");
+ xo_emit("{T:IPv6 multicast forwarding}:\n");
#define p(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
+ xo_emit(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
#define p2(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
-
- p(mrt6s_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");
- p2(mrt6s_mfc_misses, "\t%ju multicast forwarding cache miss%s\n");
- p(mrt6s_upcalls, "\t%ju upcall%s to multicast routing daemon\n");
- p(mrt6s_upq_ovflw, "\t%ju upcall queue overflow%s\n");
- p(mrt6s_upq_sockfull,
- "\t%ju upcall%s dropped due to full socket buffer\n");
- p(mrt6s_cache_cleanups, "\t%ju cache cleanup%s\n");
- p(mrt6s_no_route, "\t%ju datagram%s with no route for origin\n");
- p(mrt6s_bad_tunnel, "\t%ju datagram%s arrived with bad tunneling\n");
- p(mrt6s_cant_tunnel, "\t%ju datagram%s could not be tunneled\n");
- p(mrt6s_wrong_if, "\t%ju datagram%s arrived on wrong interface\n");
- p(mrt6s_drop_sel, "\t%ju datagram%s selectively dropped\n");
- p(mrt6s_q_overflow,
- "\t%ju datagram%s dropped due to queue overflow\n");
- p(mrt6s_pkt2large, "\t%ju datagram%s dropped for being too large\n");
+ xo_emit(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
+
+ p(mrt6s_mfc_lookups, "\t{:cache-lookups/%ju} "
+ "{N:/multicast forwarding cache lookup%s}\n");
+ p2(mrt6s_mfc_misses, "\t{:cache-misses/%ju} "
+ "{N:/multicast forwarding cache miss%s}\n");
+ p(mrt6s_upcalls, "\t{:upcalls/%ju} "
+ "{N:/upcall%s to multicast routing daemon}\n");
+ p(mrt6s_upq_ovflw, "\t{:upcall-overflows/%ju} "
+ "{N:/upcall queue overflow%s}\n");
+ p(mrt6s_upq_sockfull, "\t{:upcalls-dropped-full-buffer/%ju} "
+ "{N:/upcall%s dropped due to full socket buffer}\n");
+ p(mrt6s_cache_cleanups, "\t{:cache-cleanups/%ju} "
+ "{N:/cache cleanup%s}\n");
+ p(mrt6s_no_route, "\t{:dropped-no-origin/%ju} "
+ "{N:/datagram%s with no route for origin}\n");
+ p(mrt6s_bad_tunnel, "\t{:dropped-bad-tunnel/%ju} "
+ "{N:/datagram%s arrived with bad tunneling}\n");
+ p(mrt6s_cant_tunnel, "\t{:dropped-could-not-tunnel/%ju} "
+ "{N:/datagram%s could not be tunneled}\n");
+ p(mrt6s_wrong_if, "\t{:dropped-wrong-incoming-interface/%ju} "
+ "{N:/datagram%s arrived on wrong interface}\n");
+ p(mrt6s_drop_sel, "\t{:dropped-selectively/%ju} "
+ "{N:/datagram%s selectively dropped}\n");
+ p(mrt6s_q_overflow, "\t{:dropped-queue-overflow/%ju} "
+ "{N:/datagram%s dropped due to queue overflow}\n");
+ p(mrt6s_pkt2large, "\t{:dropped-too-large/%ju} "
+ "{N:/datagram%s dropped for being too large}\n");
#undef p2
#undef p
+ xo_close_container("multicast-statistics");
}
#endif /*INET6*/
diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c
index 9a08b6d..e28de2c 100644
--- a/usr.bin/netstat/netgraph.c
+++ b/usr.bin/netstat/netgraph.c
@@ -53,9 +53,11 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <err.h>
+#include <libxo/xo.h>
#include "netstat.h"
static int first = 1;
@@ -73,8 +75,7 @@ netgraphprotopr(u_long off, const char *name, int af1 __unused,
/* If symbol not found, try looking in the KLD module */
if (off == 0) {
if (debug)
- fprintf(stderr,
- "Error reading symbols from ng_socket.ko");
+ xo_warnx("Error reading symbols from ng_socket.ko");
return;
}
@@ -106,19 +107,21 @@ netgraphprotopr(u_long off, const char *name, int af1 __unused,
/* Do headline */
if (first) {
- printf("Netgraph sockets\n");
+ xo_emit("{T:Netgraph sockets}\n");
if (Aflag)
- printf("%-8.8s ", "PCB");
- printf("%-5.5s %-6.6s %-6.6s %-14.14s %s\n",
- "Type", "Recv-Q", "Send-Q",
- "Node Address", "#Hooks");
+ xo_emit("{T:/%-8.8s} ", "PCB");
+ xo_emit("{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} "
+ "{T:/%-14.14s} {T:/%s}\n",
+ "Type", "Recv-Q", "Send-Q", "Node Address",
+ "#Hooks");
first = 0;
}
/* Show socket */
if (Aflag)
- printf("%8lx ", (u_long) this);
- printf("%-5.5s %6u %6u ",
+ xo_emit("{:address/%8lx} ", (u_long) this);
+ xo_emit("{t:name/%-5.5s} {:receive-bytes-waiting/%6u} "
+ "{:send-byte-waiting/%6u} ",
name, sockb.so_rcv.sb_ccc, sockb.so_snd.sb_ccc);
/* Get info on associated node */
@@ -134,9 +137,9 @@ netgraphprotopr(u_long off, const char *name, int af1 __unused,
/* Display associated node info */
if (*ni->name != '\0')
snprintf(path, sizeof(path), "%s:", ni->name);
- printf("%-14.14s %4d", path, ni->hooks);
+ xo_emit("{t:path/%-14.14s} {:hooks/%4d}", path, ni->hooks);
finish:
- putchar('\n');
+ xo_emit("\n");
}
}
diff --git a/usr.bin/netstat/netisr.c b/usr.bin/netstat/netisr.c
index 6c945c3..8f6fe3d 100644
--- a/usr.bin/netstat/netisr.c
+++ b/usr.bin/netstat/netisr.c
@@ -46,8 +46,9 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
-
+#include <libxo/xo.h>
#include "netstat.h"
/*
@@ -112,13 +113,13 @@ netisr_load_kvm_uint(kvm_t *kd, const char *name, u_int *p)
ret = kvm_nlist(kd, nl);
if (ret < 0)
- errx(-1, "%s: kvm_nlist(%s): %s", __func__, name,
+ xo_errx(-1, "%s: kvm_nlist(%s): %s", __func__, name,
kvm_geterr(kd));
if (ret != 0)
- errx(-1, "%s: kvm_nlist(%s): unresolved symbol", __func__,
+ xo_errx(-1, "%s: kvm_nlist(%s): unresolved symbol", __func__,
name);
if (kvm_read(kd, nl[0].n_value, p, sizeof(*p)) != sizeof(*p))
- errx(-1, "%s: kvm_read(%s): %s", __func__, name,
+ xo_errx(-1, "%s: kvm_read(%s): %s", __func__, name,
kvm_geterr(kd));
}
@@ -134,7 +135,7 @@ netisr_load_kvm_string(kvm_t *kd, uintptr_t addr, char *dest, u_int limit)
for (i = 0; i < limit; i++) {
if (kvm_read(kd, addr + i, &dest[i], sizeof(dest[i])) !=
sizeof(dest[i]))
- err(-1, "%s: kvm_read: %s", __func__,
+ xo_err(-1, "%s: kvm_read: %s", __func__,
kvm_geterr(kd));
if (dest[i] == '\0')
break;
@@ -190,9 +191,9 @@ netisr_load_sysctl_uint(const char *name, u_int *p)
retlen = sizeof(u_int);
if (sysctlbyname(name, p, &retlen, NULL, 0) < 0)
- err(-1, "%s", name);
+ xo_err(-1, "%s", name);
if (retlen != sizeof(u_int))
- errx(-1, "%s: invalid len %ju", name, (uintmax_t)retlen);
+ xo_errx(-1, "%s: invalid len %ju", name, (uintmax_t)retlen);
}
static void
@@ -202,7 +203,7 @@ netisr_load_sysctl_string(const char *name, char *p, size_t len)
retlen = len;
if (sysctlbyname(name, p, &retlen, NULL, 0) < 0)
- err(-1, "%s", name);
+ xo_err(-1, "%s", name);
p[len - 1] = '\0';
}
@@ -241,21 +242,21 @@ netisr_load_kvm_proto(kvm_t *kd)
*/
netisr_load_kvm_uint(kd, "_netisr_maxprot", &maxprot);
if (maxprot != NETISR_MAXPROT)
- errx(-1, "%s: NETISR_MAXPROT mismatch", __func__);
+ xo_errx(-1, "%s: NETISR_MAXPROT mismatch", __func__);
len = maxprot * sizeof(*np_array);
np_array = malloc(len);
if (np_array == NULL)
- err(-1, "%s: malloc", __func__);
+ xo_err(-1, "%s: malloc", __func__);
ret = kvm_nlist(kd, nl);
if (ret < 0)
- errx(-1, "%s: kvm_nlist(_netisr_proto): %s", __func__,
+ xo_errx(-1, "%s: kvm_nlist(_netisr_proto): %s", __func__,
kvm_geterr(kd));
if (ret != 0)
- errx(-1, "%s: kvm_nlist(_netisr_proto): unresolved symbol",
+ xo_errx(-1, "%s: kvm_nlist(_netisr_proto): unresolved symbol",
__func__);
if (kvm_read(kd, nl[NLIST_NETISR_PROTO].n_value, np_array, len) !=
(ssize_t)len)
- errx(-1, "%s: kvm_read(_netisr_proto): %s", __func__,
+ xo_errx(-1, "%s: kvm_read(_netisr_proto): %s", __func__,
kvm_geterr(kd));
/*
@@ -301,21 +302,21 @@ netisr_load_sysctl_proto(void)
size_t len;
if (sysctlbyname("net.isr.proto", NULL, &len, NULL, 0) < 0)
- err(-1, "net.isr.proto: query len");
+ xo_err(-1, "net.isr.proto: query len");
if (len % sizeof(*proto_array) != 0)
- errx(-1, "net.isr.proto: invalid len");
+ xo_errx(-1, "net.isr.proto: invalid len");
proto_array = malloc(len);
if (proto_array == NULL)
- err(-1, "malloc");
+ xo_err(-1, "malloc");
if (sysctlbyname("net.isr.proto", proto_array, &len, NULL, 0) < 0)
- err(-1, "net.isr.proto: query data");
+ xo_err(-1, "net.isr.proto: query data");
if (len % sizeof(*proto_array) != 0)
- errx(-1, "net.isr.proto: invalid len");
+ xo_errx(-1, "net.isr.proto: invalid len");
proto_array_len = len / sizeof(*proto_array);
if (proto_array_len < 1)
- errx(-1, "net.isr.proto: no data");
+ xo_errx(-1, "net.isr.proto: no data");
if (proto_array[0].snp_version != sizeof(proto_array[0]))
- errx(-1, "net.isr.proto: invalid version");
+ xo_errx(-1, "net.isr.proto: invalid version");
}
static void
@@ -338,41 +339,41 @@ netisr_load_kvm_workstream(kvm_t *kd)
len = numthreads * sizeof(*nws_array);
nws_array = malloc(len);
if (nws_array == NULL)
- err(-1, "malloc");
+ xo_err(-1, "malloc");
ret = kvm_nlist(kd, nl);
if (ret < 0)
- errx(-1, "%s: kvm_nlist: %s", __func__, kvm_geterr(kd));
+ xo_errx(-1, "%s: kvm_nlist: %s", __func__, kvm_geterr(kd));
if (ret != 0)
- errx(-1, "%s: kvm_nlist: unresolved symbol", __func__);
+ xo_errx(-1, "%s: kvm_nlist: unresolved symbol", __func__);
if (kvm_read(kd, nl[NLIST_NWS_ARRAY].n_value, nws_array, len) !=
(ssize_t)len)
- errx(-1, "%s: kvm_read(_nws_array): %s", __func__,
+ xo_errx(-1, "%s: kvm_read(_nws_array): %s", __func__,
kvm_geterr(kd));
workstream_array = calloc(numthreads, sizeof(*workstream_array));
if (workstream_array == NULL)
- err(-1, "calloc");
+ xo_err(-1, "calloc");
workstream_array_len = numthreads;
work_array = calloc(numthreads * proto_array_len, sizeof(*work_array));
if (work_array == NULL)
- err(-1, "calloc");
+ xo_err(-1, "calloc");
counter = 0;
for (wsid = 0; wsid < numthreads; wsid++) {
cpuid = nws_array[wsid];
if (kvm_dpcpu_setcpu(kd, cpuid) < 0)
- errx(-1, "%s: kvm_dpcpu_setcpu(%u): %s", __func__,
+ xo_errx(-1, "%s: kvm_dpcpu_setcpu(%u): %s", __func__,
cpuid, kvm_geterr(kd));
bzero(nl_nws, sizeof(nl_nws));
nl_nws[0].n_name = "_nws";
ret = kvm_nlist(kd, nl_nws);
if (ret < 0)
- errx(-1, "%s: kvm_nlist looking up nws on CPU %u: %s",
- __func__, cpuid, kvm_geterr(kd));
+ xo_errx(-1, "%s: kvm_nlist looking up nws on CPU "
+ "%u: %s", __func__, cpuid, kvm_geterr(kd));
if (ret != 0)
- errx(-1, "%s: kvm_nlist(nws): unresolved symbol on "
+ xo_errx(-1, "%s: kvm_nlist(nws): unresolved symbol on "
"CPU %u", __func__, cpuid);
if (kvm_read(kd, nl_nws[0].n_value, &nws, sizeof(nws)) !=
sizeof(nws))
- errx(-1, "%s: kvm_read(nw): %s", __func__,
+ xo_errx(-1, "%s: kvm_read(nw): %s", __func__,
kvm_geterr(kd));
snwsp = &workstream_array[wsid];
snwsp->snws_version = sizeof(*snwsp);
@@ -384,7 +385,7 @@ netisr_load_kvm_workstream(kvm_t *kd)
/*
* Extract the CPU's per-protocol work information.
*/
- printf("counting to maxprot: %u\n", maxprot);
+ xo_emit("counting to maxprot: {:maxprot/%u}\n", maxprot);
for (proto = 0; proto < maxprot; proto++) {
if (!netisr_protoispresent(proto))
continue;
@@ -413,22 +414,22 @@ netisr_load_sysctl_workstream(void)
size_t len;
if (sysctlbyname("net.isr.workstream", NULL, &len, NULL, 0) < 0)
- err(-1, "net.isr.workstream: query len");
+ xo_err(-1, "net.isr.workstream: query len");
if (len % sizeof(*workstream_array) != 0)
- errx(-1, "net.isr.workstream: invalid len");
+ xo_errx(-1, "net.isr.workstream: invalid len");
workstream_array = malloc(len);
if (workstream_array == NULL)
- err(-1, "malloc");
+ xo_err(-1, "malloc");
if (sysctlbyname("net.isr.workstream", workstream_array, &len, NULL,
0) < 0)
- err(-1, "net.isr.workstream: query data");
+ xo_err(-1, "net.isr.workstream: query data");
if (len % sizeof(*workstream_array) != 0)
- errx(-1, "net.isr.workstream: invalid len");
+ xo_errx(-1, "net.isr.workstream: invalid len");
workstream_array_len = len / sizeof(*workstream_array);
if (workstream_array_len < 1)
- errx(-1, "net.isr.workstream: no data");
+ xo_errx(-1, "net.isr.workstream: no data");
if (workstream_array[0].snws_version != sizeof(workstream_array[0]))
- errx(-1, "net.isr.workstream: invalid version");
+ xo_errx(-1, "net.isr.workstream: invalid version");
}
static void
@@ -437,21 +438,21 @@ netisr_load_sysctl_work(void)
size_t len;
if (sysctlbyname("net.isr.work", NULL, &len, NULL, 0) < 0)
- err(-1, "net.isr.work: query len");
+ xo_err(-1, "net.isr.work: query len");
if (len % sizeof(*work_array) != 0)
- errx(-1, "net.isr.work: invalid len");
+ xo_errx(-1, "net.isr.work: invalid len");
work_array = malloc(len);
if (work_array == NULL)
- err(-1, "malloc");
+ xo_err(-1, "malloc");
if (sysctlbyname("net.isr.work", work_array, &len, NULL, 0) < 0)
- err(-1, "net.isr.work: query data");
+ xo_err(-1, "net.isr.work: query data");
if (len % sizeof(*work_array) != 0)
- errx(-1, "net.isr.work: invalid len");
+ xo_errx(-1, "net.isr.work: invalid len");
work_array_len = len / sizeof(*work_array);
if (work_array_len < 1)
- errx(-1, "net.isr.work: no data");
+ xo_errx(-1, "net.isr.work: no data");
if (work_array[0].snw_version != sizeof(work_array[0]))
- errx(-1, "net.isr.work: invalid version");
+ xo_errx(-1, "net.isr.work: invalid version");
}
static void
@@ -459,17 +460,17 @@ netisr_print_proto(struct sysctl_netisr_proto *snpp)
{
char tmp[20];
- printf("%-6s", snpp->snp_name);
- printf(" %5u", snpp->snp_proto);
- printf(" %6u", snpp->snp_qlimit);
- printf(" %6s",
+ xo_emit("{[:-6}{k:name/%s}{]:}", snpp->snp_name);
+ xo_emit(" {:protocol/%5u}", snpp->snp_proto);
+ xo_emit(" {:queue-limit/%6u}", snpp->snp_qlimit);
+ xo_emit(" {:policy-type/%6s}",
(snpp->snp_policy == NETISR_POLICY_SOURCE) ? "source" :
(snpp->snp_policy == NETISR_POLICY_FLOW) ? "flow" :
(snpp->snp_policy == NETISR_POLICY_CPU) ? "cpu" : "-");
netisr_dispatch_policy_to_string(snpp->snp_dispatch, tmp,
sizeof(tmp));
- printf(" %8s", tmp);
- printf(" %s%s%s\n",
+ xo_emit(" {:policy/%8s}", tmp);
+ xo_emit(" {:flags/%s%s%s}\n",
(snpp->snp_flags & NETISR_SNP_FLAGS_M2CPUID) ? "C" : "-",
(snpp->snp_flags & NETISR_SNP_FLAGS_DRAINEDCPU) ? "D" : "-",
(snpp->snp_flags & NETISR_SNP_FLAGS_M2FLOW) ? "F" : "-");
@@ -481,23 +482,28 @@ netisr_print_workstream(struct sysctl_netisr_workstream *snwsp)
struct sysctl_netisr_work *snwp;
u_int i;
+ xo_open_list("work");
for (i = 0; i < work_array_len; i++) {
snwp = &work_array[i];
if (snwp->snw_wsid != snwsp->snws_wsid)
continue;
- printf("%4u ", snwsp->snws_wsid);
- printf("%3u ", snwsp->snws_cpu);
- printf("%2s", "");
- printf("%-6s", netisr_proto2name(snwp->snw_proto));
- printf(" %5u", snwp->snw_len);
- printf(" %5u", snwp->snw_watermark);
- printf(" %8ju", snwp->snw_dispatched);
- printf(" %8ju", snwp->snw_hybrid_dispatched);
- printf(" %8ju", snwp->snw_qdrops);
- printf(" %8ju", snwp->snw_queued);
- printf(" %8ju", snwp->snw_handled);
- printf("\n");
+ xo_open_instance("work");
+ xo_emit("{t:workstream/%4u} ", snwsp->snws_wsid);
+ xo_emit("{t:cpu/%3u} ", snwsp->snws_cpu);
+ xo_emit("{P: }");
+ xo_emit("{t:name/%-6s}", netisr_proto2name(snwp->snw_proto));
+ xo_emit(" {t:length/%5u}", snwp->snw_len);
+ xo_emit(" {t:watermark/%5u}", snwp->snw_watermark);
+ xo_emit(" {t:dispatched/%8ju}", snwp->snw_dispatched);
+ xo_emit(" {t:hybrid-dispatched/%8ju}",
+ snwp->snw_hybrid_dispatched);
+ xo_emit(" {t:queue-drops/%8ju}", snwp->snw_qdrops);
+ xo_emit(" {t:queued/%8ju}", snwp->snw_queued);
+ xo_emit(" {t:handled/%8ju}", snwp->snw_handled);
+ xo_emit("\n");
+ xo_close_instance("work");
}
+ xo_close_list("work");
}
void
@@ -515,39 +521,55 @@ netisr_stats(void *kvmd)
netisr_load_sysctl_work();
} else {
if (kd == NULL)
- errx(-1, "netisr_stats: !live but !kd");
+ xo_errx(-1, "netisr_stats: !live but !kd");
netisr_load_kvm_config(kd);
netisr_load_kvm_proto(kd);
netisr_load_kvm_workstream(kd); /* Also does work. */
}
- printf("Configuration:\n");
- printf("%-25s %12s %12s\n", "Setting", "Current", "Limit");
- printf("%-25s %12u %12u\n", "Thread count", numthreads, maxthreads);
- printf("%-25s %12u %12u\n", "Default queue limit", defaultqlimit,
- maxqlimit);
- printf("%-25s %12s %12s\n", "Dispatch policy", dispatch_policy,
+ xo_open_container("netisr");
+
+ xo_emit("{T:Configuration}:\n");
+ xo_emit("{T:/%-25s} {T:/%12s} {T:/%12s}\n",
+ "Setting", "Current", "Limit");
+ xo_emit("{T:/%-25s} {T:/%12u} {T:/%12u}\n",
+ "Thread count", numthreads, maxthreads);
+ xo_emit("{T:/%-25s} {T:/%12u} {T:/%12u}\n",
+ "Default queue limit", defaultqlimit, maxqlimit);
+ xo_emit("{T:/%-25s} {T:/%12s} {T:/%12s}\n",
+ "Dispatch policy", dispatch_policy, "n/a");
+ xo_emit("{T:/%-25s} {T:/%12s} {T:/%12s}\n",
+ "Threads bound to CPUs", bindthreads ? "enabled" : "disabled",
"n/a");
- printf("%-25s %12s %12s\n", "Threads bound to CPUs",
- bindthreads ? "enabled" : "disabled", "n/a");
- printf("\n");
+ xo_emit("\n");
- printf("Protocols:\n");
- printf("%-6s %5s %6s %-6s %-8s %-5s\n", "Name", "Proto", "QLimit",
- "Policy", "Dispatch", "Flags");
+ xo_emit("{T:Protocols}:\n");
+ xo_emit("{T:/%-6s} {T:/%5s} {T:/%6s} {T:/%-6s} {T:/%-8s} {T:/%-5s}\n",
+ "Name", "Proto", "QLimit", "Policy", "Dispatch", "Flags");
+ xo_open_list("protocol");
for (i = 0; i < proto_array_len; i++) {
+ xo_open_instance("protocol");
snpp = &proto_array[i];
netisr_print_proto(snpp);
+ xo_close_instance("protocol");
}
- printf("\n");
-
- printf("Workstreams:\n");
- printf("%4s %3s ", "WSID", "CPU");
- printf("%2s", "");
- printf("%-6s %5s %5s %8s %8s %8s %8s %8s\n", "Name", "Len", "WMark",
- "Disp'd", "HDisp'd", "QDrops", "Queued", "Handled");
+ xo_close_list("protocol");
+ xo_emit("\n");
+
+ xo_emit("{T:Workstreams}:\n");
+ xo_emit("{T:/%4s} {T:/%3s} ", "WSID", "CPU");
+ xo_emit("{P:/%2s}", "");
+ xo_emit("{T:/%-6s} {T:/%5s} {T:/%5s} {T:/%8s} {T:/%8s} {T:/%8s} "
+ "{T:/%8s} {T:/%8s}\n",
+ "Name", "Len", "WMark", "Disp'd", "HDisp'd", "QDrops", "Queued",
+ "Handled");
+ xo_open_list("workstream");
for (i = 0; i < workstream_array_len; i++) {
+ xo_open_instance("workstream");
snwsp = &workstream_array[i];
netisr_print_workstream(snwsp);
+ xo_close_instance("workstream");
}
+ xo_close_list("workstream");
+ xo_close_container("netisr");
}
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index 1f2bb01..1b67b1a 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -28,7 +28,7 @@
.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd June 4, 2014
+.Dd February 21, 2015
.Dt NETSTAT 1
.Os
.Sh NAME
@@ -38,58 +38,70 @@
.Bk -words
.Bl -tag -width "netstat"
.It Nm
+.Op Fl -libxo
.Op Fl 46AaLnRSTWx
.Op Fl f Ar protocol_family | Fl p Ar protocol
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl i | I Ar interface
+.Op Fl -libxo
.Op Fl 46abdhnW
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl w Ar wait
+.Op Fl -libxo
.Op Fl I Ar interface
.Op Fl 46d
.Op Fl M Ar core
.Op Fl N Ar system
.Op Fl q Ar howmany
.It Nm Fl s
+.Op Fl -libxo
.Op Fl 46sz
.Op Fl f Ar protocol_family | Fl p Ar protocol
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl i | I Ar interface Fl s
+.Op Fl -libxo
.Op Fl 46s
.Op Fl f Ar protocol_family | Fl p Ar protocol
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl m
+.Op Fl -libxo
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl B
+.Op Fl -libxo
.Op Fl z
.Op Fl I Ar interface
.It Nm Fl r
+.Op Fl -libxo
.Op Fl 46AnW
.Op Fl F Ar fibnum
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl rs
+.Op Fl -libxo
.Op Fl s
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl g
+.Op Fl -libxo
.Op Fl 46W
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl gs
+.Op Fl -libxo
.Op Fl 46s
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
.It Nm Fl Q
+.Op Fl -libxo
.El
.Ek
.Sh DESCRIPTION
@@ -784,6 +796,8 @@ and display them symbolically.
.Xr procstat 1 ,
.Xr ps 1 ,
.Xr sockstat 1 ,
+.Xr libxo 3 ,
+.Xr xo_parse_args 3 ,
.Xr bpf 4 ,
.Xr inet 4 ,
.Xr route 4 ,
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index cb46c0f..29e4d0f 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -108,7 +108,7 @@ struct in6_addr;
void in6_fillscopeid(struct sockaddr_in6 *);
char *routename6(struct sockaddr_in6 *);
const char *netname6(struct sockaddr_in6 *, struct in6_addr *);
-void inet6print(struct in6_addr *, int, const char *, int);
+void inet6print(const char *, struct in6_addr *, int, const char *, int);
#endif /*INET6*/
#ifdef IPSEC
@@ -143,7 +143,7 @@ void nserr_stats(u_long, const char *, int, int);
void netgraphprotopr(u_long, const char *, int, int);
#endif
-void unixpr(u_long, u_long, u_long, u_long, u_long);
+void unixpr(u_long, u_long, u_long, u_long, u_long, bool *);
void esis_stats(u_long, const char *, int, int);
void clnp_stats(u_long, const char *, int, int);
diff --git a/usr.bin/netstat/pfkey.c b/usr.bin/netstat/pfkey.c
index da81485..fbf330f 100644
--- a/usr.bin/netstat/pfkey.c
+++ b/usr.bin/netstat/pfkey.c
@@ -81,6 +81,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <stdbool.h>
+#include <libxo/xo.h>
#include "netstat.h"
#ifdef IPSEC
@@ -118,59 +120,89 @@ pfkey_stats(u_long off, const char *name, int family __unused,
if (off == 0)
return;
- printf ("%s:\n", name);
+ xo_emit("{T:/%s}:\n", name);
+ xo_open_container(name);
kread_counters(off, (char *)&pfkeystat, sizeof(pfkeystat));
#define p(f, m) if (pfkeystat.f || sflag <= 1) \
- printf(m, (uintmax_t)pfkeystat.f, plural(pfkeystat.f))
+ xo_emit(m, (uintmax_t)pfkeystat.f, plural(pfkeystat.f))
/* userland -> kernel */
- p(out_total, "\t%ju request%s sent from userland\n");
- p(out_bytes, "\t%ju byte%s sent from userland\n");
+ p(out_total, "\t{:sent-requests//%ju} "
+ "{N:/request%s sent from userland}\n");
+ p(out_bytes, "\t{:sent-bytes/%ju} "
+ "{N:/byte%s sent from userland}\n");
for (first = 1, type = 0;
- type < sizeof(pfkeystat.out_msgtype)/sizeof(pfkeystat.out_msgtype[0]);
- type++) {
+ type<sizeof(pfkeystat.out_msgtype)/sizeof(pfkeystat.out_msgtype[0]);
+ type++) {
if (pfkeystat.out_msgtype[type] <= 0)
continue;
if (first) {
- printf("\thistogram by message type:\n");
+ xo_open_list("output-histogram");
+ xo_emit("\t{T:histogram by message type}:\n");
first = 0;
}
- printf("\t\t%s: %ju\n", pfkey_msgtype_names(type),
- (uintmax_t)pfkeystat.out_msgtype[type]);
+ xo_open_instance("output-histogram");
+ xo_emit("\t\t{k::type/%s}: {:count/%ju}\n",
+ pfkey_msgtype_names(type),
+ (uintmax_t)pfkeystat.out_msgtype[type]);
+ xo_close_instance("output-histogram");
}
- p(out_invlen, "\t%ju message%s with invalid length field\n");
- p(out_invver, "\t%ju message%s with invalid version field\n");
- p(out_invmsgtype, "\t%ju message%s with invalid message type field\n");
- p(out_tooshort, "\t%ju message%s too short\n");
- p(out_nomem, "\t%ju message%s with memory allocation failure\n");
- p(out_dupext, "\t%ju message%s with duplicate extension\n");
- p(out_invexttype, "\t%ju message%s with invalid extension type\n");
- p(out_invsatype, "\t%ju message%s with invalid sa type\n");
- p(out_invaddr, "\t%ju message%s with invalid address extension\n");
+ if (!first)
+ xo_close_list("output-histogram");
+
+ p(out_invlen, "\t{:dropped-bad-length/%ju} "
+ "{N:/message%s with invalid length field}\n");
+ p(out_invver, "\t{:dropped-bad-version/%ju} "
+ "{N:/message%s with invalid version field}\n");
+ p(out_invmsgtype, "\t{:dropped-bad-type/%ju} "
+ "{N:/message%s with invalid message type field}\n");
+ p(out_tooshort, "\t{:dropped-too-short/%ju} "
+ "{N:/message%s too short}\n");
+ p(out_nomem, "\t{:dropped-no-memory/%ju} "
+ "{N:/message%s with memory allocation failure}\n");
+ p(out_dupext, "\t{:dropped-duplicate-extension/%ju} "
+ "{N:/message%s with duplicate extension}\n");
+ p(out_invexttype, "\t{:dropped-bad-extension/%ju} "
+ "{N:/message%s with invalid extension type}\n");
+ p(out_invsatype, "\t:dropped-bad-sa-type/%ju} "
+ "{N:/message%s with invalid sa type}\n");
+ p(out_invaddr, "\t{:dropped-bad-address-extension/%ju} "
+ "{N:/message%s with invalid address extension}\n");
/* kernel -> userland */
- p(in_total, "\t%ju request%s sent to userland\n");
- p(in_bytes, "\t%ju byte%s sent to userland\n");
+ p(in_total, "\t{:received-requests/%ju} "
+ "{N:/request%s sent to userland}\n");
+ p(in_bytes, "\t{:received-bytes/%ju} "
+ "{N:/byte%s sent to userland}\n");
for (first = 1, type = 0;
- type < sizeof(pfkeystat.in_msgtype)/sizeof(pfkeystat.in_msgtype[0]);
- type++) {
+ type < sizeof(pfkeystat.in_msgtype)/sizeof(pfkeystat.in_msgtype[0]);
+ type++) {
if (pfkeystat.in_msgtype[type] <= 0)
continue;
if (first) {
- printf("\thistogram by message type:\n");
+ xo_open_list("input-histogram");
+ xo_emit("\t{T:histogram by message type}:\n");
first = 0;
}
- printf("\t\t%s: %ju\n", pfkey_msgtype_names(type),
- (uintmax_t)pfkeystat.in_msgtype[type]);
+ xo_open_instance("input-histogram");
+ xo_emit("\t\t{k:type/%s}: {:count/%ju}\n",
+ pfkey_msgtype_names(type),
+ (uintmax_t)pfkeystat.in_msgtype[type]);
+ xo_close_instance("input-histogram");
}
- p(in_msgtarget[KEY_SENDUP_ONE],
- "\t%ju message%s toward single socket\n");
- p(in_msgtarget[KEY_SENDUP_ALL],
- "\t%ju message%s toward all sockets\n");
+ if (!first)
+ xo_close_list("input-histogram");
+ p(in_msgtarget[KEY_SENDUP_ONE], "\t{:received-one-socket/%ju} "
+ "{N:/message%s toward single socket}\n");
+ p(in_msgtarget[KEY_SENDUP_ALL], "\t{:received-all-sockets/%ju} "
+ "{N:/message%s toward all sockets}\n");
p(in_msgtarget[KEY_SENDUP_REGISTERED],
- "\t%ju message%s toward registered sockets\n");
- p(in_nomem, "\t%ju message%s with memory allocation failure\n");
+ "\t{:received-registered-sockets/%ju} "
+ "{N:/message%s toward registered sockets}\n");
+ p(in_nomem, "\t{:discarded-no-memory/%ju} "
+ "{N:/message%s with memory allocation failure}\n");
#undef p
+ xo_close_container(name);
}
#endif /* IPSEC */
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 7555615..5ae40b1 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -64,10 +64,12 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#include <err.h>
+#include <libxo/xo.h>
#include "netstat.h"
#define kget(p, d) (kread((u_long)(p), (char *)&(d), sizeof (d)))
@@ -78,25 +80,26 @@ __FBSDID("$FreeBSD$");
struct bits {
u_long b_mask;
char b_val;
+ const char *b_name;
} bits[] = {
- { RTF_UP, 'U' },
- { RTF_GATEWAY, 'G' },
- { RTF_HOST, 'H' },
- { RTF_REJECT, 'R' },
- { RTF_DYNAMIC, 'D' },
- { RTF_MODIFIED, 'M' },
- { RTF_DONE, 'd' }, /* Completed -- for routing messages only */
- { RTF_XRESOLVE, 'X' },
- { RTF_STATIC, 'S' },
- { RTF_PROTO1, '1' },
- { RTF_PROTO2, '2' },
- { RTF_PROTO3, '3' },
- { RTF_BLACKHOLE,'B' },
- { RTF_BROADCAST,'b' },
+ { RTF_UP, 'U', "up" },
+ { RTF_GATEWAY, 'G', "gateway" },
+ { RTF_HOST, 'H', "host" },
+ { RTF_REJECT, 'R', "reject" },
+ { RTF_DYNAMIC, 'D', "dynamic" },
+ { RTF_MODIFIED, 'M', "modified" },
+ { RTF_DONE, 'd', "done" }, /* Completed -- for routing msgs only */
+ { RTF_XRESOLVE, 'X', "xresolve" },
+ { RTF_STATIC, 'S', "static" },
+ { RTF_PROTO1, '1', "proto1" },
+ { RTF_PROTO2, '2', "proto2" },
+ { RTF_PROTO3, '3', "proto3" },
+ { RTF_BLACKHOLE,'B', "blackhole" },
+ { RTF_BROADCAST,'b', "broadcast" },
#ifdef RTF_LLINFO
- { RTF_LLINFO, 'L' },
+ { RTF_LLINFO, 'L', "llinfo" },
#endif
- { 0 , 0 }
+ { 0 , 0, NULL }
};
/*
@@ -143,14 +146,15 @@ static void size_cols_rtentry(struct rtentry *rt);
static void p_rtnode_kvm(void);
static void p_rtable_sysctl(int, int);
static void p_rtable_kvm(int, int );
-static void p_rtree_kvm(struct radix_node *);
-static void p_rtentry_sysctl(struct rt_msghdr *);
-static void p_sockaddr(struct sockaddr *, struct sockaddr *, int, int);
+static void p_rtree_kvm(const char *name, struct radix_node *);
+static void p_rtentry_kvm(const char *name, struct rtentry *);
+static void p_rtentry_sysctl(const char *name, struct rt_msghdr *);
+static void p_sockaddr(const char *name, struct sockaddr *, struct sockaddr *,
+ int, int);
static const char *fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask,
int flags);
static void p_flags(int, const char *);
static const char *fmt_flags(int f);
-static void p_rtentry_kvm(struct rtentry *);
static void domask(char *, in_addr_t, u_long);
/*
@@ -178,15 +182,17 @@ routepr(int fibnum, int af)
if (clock_gettime(CLOCK_UPTIME, &uptime) < 0)
err(EX_OSERR, "clock_gettime() failed");
- printf("Routing tables");
+ xo_open_container("route-information");
+ xo_emit("{T:Routing tables}");
if (fibnum)
- printf(" (fib: %d)", fibnum);
- printf("\n");
+ xo_emit(" ({L:fib}: {:fib/%d})", fibnum);
+ xo_emit("\n");
if (Aflag == 0 && live != 0 && NewTree)
p_rtable_sysctl(fibnum, af);
else
p_rtable_kvm(fibnum, af);
+ xo_close_container("route-information");
}
@@ -221,9 +227,9 @@ pr_family(int af1)
break;
}
if (afname)
- printf("\n%s:\n", afname);
+ xo_emit("\n{k:address-family/%s}:\n", afname);
else
- printf("\nProtocol Family %d:\n", af1);
+ xo_emit("\n{L:Protocol Family} {k:address-family/%d}:\n", af1);
}
/* column widths; each followed by one space */
@@ -320,7 +326,7 @@ size_cols_rtentry(struct rtentry *rt)
}
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
- if (kget(rt->rt_ifp, ifnet) == 0)
+ if (kget(rt->rt_ifp, ifnet) == 0)
len = strlen(ifnet.if_xname);
else
len = strlen("---");
@@ -333,7 +339,7 @@ size_cols_rtentry(struct rtentry *rt)
if ((expire_time =
rt->rt_expire - uptime.tv_sec) > 0) {
len = snprintf(buffer, sizeof(buffer), "%d",
- (int)expire_time);
+ (int)expire_time);
wid_expire = MAX(len, wid_expire);
}
}
@@ -349,9 +355,10 @@ pr_rthdr(int af1)
{
if (Aflag)
- printf("%-8.8s ","Address");
+ xo_emit("{T:/%-8.8s} ","Address");
if (Wflag) {
- printf("%-*.*s %-*.*s %-*.*s %*.*s %*.*s %*.*s %*s\n",
+ xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%*.*s} "
+ "{T:/%*.*s} {T:/%*.*s} {T:/%*.*s} {T:/%*s}\n",
wid_dst, wid_dst, "Destination",
wid_gw, wid_gw, "Gateway",
wid_flags, wid_flags, "Flags",
@@ -360,7 +367,8 @@ pr_rthdr(int af1)
wid_if, wid_if, "Netif",
wid_expire, "Expire");
} else {
- printf("%-*.*s %-*.*s %-*.*s %*.*s %*s\n",
+ xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%*.*s} "
+ "{T:/%*s}\n",
wid_dst, wid_dst, "Destination",
wid_gw, wid_gw, "Gateway",
wid_flags, wid_flags, "Flags",
@@ -391,10 +399,11 @@ p_rtable_kvm(int fibnum, int af)
struct radix_node_head **rt_tables;
u_long rtree;
int fam, af_size;
+ bool did_rt_family = false;
kresolve_list(rl);
if ((rtree = rl[N_RTREE].n_value) == 0) {
- printf("rt_tables: symbol not in namelist\n");
+ xo_emit("rt_tables: symbol not in namelist\n");
return;
}
@@ -406,6 +415,7 @@ p_rtable_kvm(int fibnum, int af)
if (kread((u_long)(rtree), (char *)(rt_tables) + fibnum * af_size,
af_size) != 0)
err(EX_OSERR, "error retrieving radix pointers");
+ xo_open_container("route-table");
for (fam = 0; fam <= AF_MAX; fam++) {
int tmpfib;
@@ -430,17 +440,30 @@ p_rtable_kvm(int fibnum, int af)
continue;
if (fam == AF_UNSPEC) {
if (Aflag && af == 0) {
- printf("Netmasks:\n");
- p_rtree_kvm(head.rnh_treetop);
+ xo_emit("{T:Netmasks}:\n");
+ xo_open_list("netmasks");
+ p_rtree_kvm("netmasks", head.rnh_treetop);
+ xo_close_list("netmasks");
}
} else if (af == AF_UNSPEC || af == fam) {
+ if (!did_rt_family) {
+ xo_open_list("rt-family");
+ did_rt_family = true;
+ }
size_cols(fam, head.rnh_treetop);
+ xo_open_instance("rt-family");
pr_family(fam);
do_rtent = 1;
+ xo_open_list("rt-entry");
pr_rthdr(fam);
- p_rtree_kvm(head.rnh_treetop);
+ p_rtree_kvm("rt-entry", head.rnh_treetop);
+ xo_close_list("rt-entry");
+ xo_close_instance("rt-family");
}
}
+ if (did_rt_family)
+ xo_close_list("rt-family");
+ xo_close_container("route-table");
free(rt_tables);
}
@@ -450,8 +473,18 @@ p_rtable_kvm(int fibnum, int af)
* debugging kvm(3) interface.
*/
static void
-p_rtree_kvm(struct radix_node *rn)
+p_rtree_kvm(const char *name, struct radix_node *rn)
{
+ bool opened;
+
+ opened = false;
+
+#define DOOPEN() do { \
+ if (!opened) { xo_open_instance(name); opened = true; } \
+ } while (0)
+#define DOCLOSE() do { \
+ if (opened) { opened = false; xo_close_instance(name); } \
+ } while(0)
again:
if (kget(rn, rnode) != 0)
@@ -459,33 +492,46 @@ again:
if (!(rnode.rn_flags & RNF_ACTIVE))
return;
if (rnode.rn_bit < 0) {
- if (Aflag)
- printf("%-8.8lx ", (u_long)rn);
+ if (Aflag) {
+ DOOPEN();
+ xo_emit("{q:radix-node/%-8.8lx} ", (u_long)rn);
+ }
if (rnode.rn_flags & RNF_ROOT) {
- if (Aflag)
- printf("(root node)%s",
+ if (Aflag) {
+ DOOPEN();
+ xo_emit("({:root/root} node){L:/%s}",
rnode.rn_dupedkey ? " =>\n" : "\n");
+ }
} else if (do_rtent) {
if (kget(rn, rtentry) == 0) {
- p_rtentry_kvm(&rtentry);
- if (Aflag)
+ DOOPEN();
+ p_rtentry_kvm(name, &rtentry);
+ if (Aflag) {
+ DOOPEN();
p_rtnode_kvm();
+ DOCLOSE();
+ }
}
} else {
- p_sockaddr(kgetsa((struct sockaddr *)rnode.rn_key),
- NULL, 0, 44);
- putchar('\n');
+ DOOPEN();
+ p_sockaddr("address",
+ kgetsa((struct sockaddr *)rnode.rn_key),
+ NULL, 0, 44);
+ xo_emit("\n");
}
+ DOCLOSE();
if ((rn = rnode.rn_dupedkey))
goto again;
} else {
if (Aflag && do_rtent) {
- printf("%-8.8lx ", (u_long)rn);
+ DOOPEN();
+ xo_emit("{q:radix-node/%-8.8lx} ", (u_long)rn);
p_rtnode_kvm();
+ DOCLOSE();
}
rn = rnode.rn_right;
- p_rtree_kvm(rnode.rn_left);
- p_rtree_kvm(rn);
+ p_rtree_kvm(name, rnode.rn_left);
+ p_rtree_kvm(name, rn);
}
}
@@ -498,37 +544,41 @@ p_rtnode_kvm(void)
if (rnode.rn_bit < 0) {
if (rnode.rn_mask) {
- printf("\t mask ");
- p_sockaddr(kgetsa((struct sockaddr *)rnode.rn_mask),
- NULL, 0, -1);
+ xo_emit("\t {L:mask} ");
+ p_sockaddr("netmask",
+ kgetsa((struct sockaddr *)rnode.rn_mask),
+ NULL, 0, -1);
} else if (rm == 0)
return;
} else {
- sprintf(nbuf, "(%d)", rnode.rn_bit);
- printf("%6.6s %8.8lx : %8.8lx", nbuf, (u_long)rnode.rn_left, (u_long)rnode.rn_right);
+ xo_emit("{[:6}{:bit/(%d)}{]:} {q:left-node/%8.8lx} "
+ ": {q:right-node/%8.8lx}", rnode.rn_bit,
+ (u_long)rnode.rn_left, (u_long)rnode.rn_right);
}
while (rm) {
if (kget(rm, rmask) != 0)
break;
sprintf(nbuf, " %d refs, ", rmask.rm_refs);
- printf(" mk = %8.8lx {(%d),%s",
- (u_long)rm, -1 - rmask.rm_bit, rmask.rm_refs ? nbuf : " ");
+ xo_emit(" mk = {q:node/%8.8lx} \\{({:bit/%d}),{nbufs/%s}",
+ (u_long)rm, -1 - rmask.rm_bit, rmask.rm_refs ? nbuf : " ");
if (rmask.rm_flags & RNF_NORMAL) {
struct radix_node rnode_aux;
- printf(" <normal>, ");
+ xo_emit(" <{:mode/normal}>, ");
if (kget(rmask.rm_leaf, rnode_aux) == 0)
- p_sockaddr(kgetsa((struct sockaddr *)rnode_aux.rn_mask),
+ p_sockaddr("netmask",
+ kgetsa(/*XXX*/(void *)rnode_aux.rn_mask),
NULL, 0, -1);
else
- p_sockaddr(NULL, NULL, 0, -1);
+ p_sockaddr(NULL, NULL, NULL, 0, -1);
} else
- p_sockaddr(kgetsa((struct sockaddr *)rmask.rm_mask),
- NULL, 0, -1);
- putchar('}');
+ p_sockaddr("netmask",
+ kgetsa((struct sockaddr *)rmask.rm_mask),
+ NULL, 0, -1);
+ xo_emit("\\}");
if ((rm = rmask.rm_mklist))
- printf(" ->");
+ xo_emit(" {D:->}");
}
- putchar('\n');
+ xo_emit("\n");
}
static void
@@ -539,7 +589,8 @@ p_rtable_sysctl(int fibnum, int af)
char *buf, *next, *lim;
struct rt_msghdr *rtm;
struct sockaddr *sa;
- int fam = 0, ifindex = 0, size;
+ int fam = AF_UNSPEC, ifindex = 0, size;
+ int need_table_close = false;
struct ifaddrs *ifap, *ifa;
struct sockaddr_dl *sdl;
@@ -566,7 +617,7 @@ p_rtable_sysctl(int fibnum, int af)
errx(2, "realloc(%d) failed", size);
memset(&ifmap[ifmap_size], 0,
size - ifmap_size *
- sizeof(struct ifmap_entry));
+ sizeof(struct ifmap_entry));
ifmap_size = roundup(ifindex + 1, 32);
}
@@ -594,6 +645,8 @@ p_rtable_sysctl(int fibnum, int af)
if (sysctl(mib, nitems(mib), buf, &needed, NULL, 0) < 0)
err(1, "sysctl: net.route.0.%d.dump.%d", af, fibnum);
lim = buf + needed;
+ xo_open_container("route-table");
+ xo_open_list("rt-family");
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
if (rtm->rtm_version != RTM_VERSION)
@@ -602,19 +655,35 @@ p_rtable_sysctl(int fibnum, int af)
* Peek inside header to determine AF
*/
sa = (struct sockaddr *)(rtm + 1);
+ /* Only print family first time. */
if (fam != sa->sa_family) {
+ if (need_table_close) {
+ xo_close_list("rt-entry");
+ xo_close_instance("rt-family");
+ }
+ need_table_close = true;
+
fam = sa->sa_family;
size_cols(fam, NULL);
+ xo_open_instance("rt-family");
pr_family(fam);
+ xo_open_list("rt-entry");
+
pr_rthdr(fam);
}
- p_rtentry_sysctl(rtm);
+ p_rtentry_sysctl("rt-entry", rtm);
+ }
+ if (need_table_close) {
+ xo_close_list("rt-entry");
+ xo_close_instance("rt-family");
}
+ xo_close_list("rt-family");
+ xo_close_container("route-table");
free(buf);
}
static void
-p_rtentry_sysctl(struct rt_msghdr *rtm)
+p_rtentry_sysctl(const char *name, struct rt_msghdr *rtm)
{
struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
char buffer[128];
@@ -622,6 +691,8 @@ p_rtentry_sysctl(struct rt_msghdr *rtm)
sa_u addr, mask, gw;
unsigned int l;
+ xo_open_instance(name);
+
#define GETSA(_s, _f) { \
bzero(&(_s), sizeof(_s)); \
if (rtm->rtm_addrs & _f) { \
@@ -634,18 +705,20 @@ p_rtentry_sysctl(struct rt_msghdr *rtm)
GETSA(addr, RTA_DST);
GETSA(gw, RTA_GATEWAY);
GETSA(mask, RTA_NETMASK);
- p_sockaddr(&addr.u_sa, &mask.u_sa, rtm->rtm_flags, wid_dst);
- p_sockaddr(&gw.u_sa, NULL, RTF_HOST, wid_gw);
- snprintf(buffer, sizeof(buffer), "%%-%d.%ds ", wid_flags, wid_flags);
+ p_sockaddr("destination", &addr.u_sa, &mask.u_sa, rtm->rtm_flags,
+ wid_dst);
+ p_sockaddr("gateway", &gw.u_sa, NULL, RTF_HOST, wid_gw);
+ snprintf(buffer, sizeof(buffer), "{[:-%d}{:flags/%%s}{]:}",
+ wid_flags);
p_flags(rtm->rtm_flags, buffer);
if (Wflag) {
- printf("%*lu ", wid_pksent, rtm->rtm_rmx.rmx_pksent);
+ xo_emit("{t:use/%*lu} ", wid_pksent, rtm->rtm_rmx.rmx_pksent);
if (rtm->rtm_rmx.rmx_mtu != 0)
- printf("%*lu ", wid_mtu, rtm->rtm_rmx.rmx_mtu);
+ xo_emit("{t:mtu/%*lu} ", wid_mtu, rtm->rtm_rmx.rmx_mtu);
else
- printf("%*s ", wid_mtu, "");
+ xo_emit("{P:/%*s} ", wid_mtu, "");
}
memset(prettyname, 0, sizeof(prettyname));
@@ -656,32 +729,41 @@ p_rtentry_sysctl(struct rt_msghdr *rtm)
strlcpy(prettyname, "---", sizeof(prettyname));
}
- printf("%*.*s", wid_if, wid_if, prettyname);
+ xo_emit("{t:interface-name/%*.*s}", wid_if, wid_if, prettyname);
if (rtm->rtm_rmx.rmx_expire) {
time_t expire_time;
- if ((expire_time =
- rtm->rtm_rmx.rmx_expire - uptime.tv_sec) > 0)
- printf(" %*d", wid_expire, (int)expire_time);
+ if ((expire_time = rtm->rtm_rmx.rmx_expire - uptime.tv_sec) > 0)
+ xo_emit(" {:expire-time/%*d}", wid_expire,
+ (int)expire_time);
}
- putchar('\n');
+ xo_emit("\n");
+ xo_close_instance(name);
}
static void
-p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width)
+p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask,
+ int flags, int width)
{
const char *cp;
+ char buf[128];
cp = fmt_sockaddr(sa, mask, flags);
- if (width < 0 )
- printf("%s ", cp);
- else {
- if (numeric_addr)
- printf("%-*s ", width, cp);
- else
- printf("%-*.*s ", width, width, cp);
+ if (width < 0) {
+ snprintf(buf, sizeof(buf), "{:%s/%%s} ", name);
+ xo_emit(buf, cp);
+ } else {
+ if (numeric_addr) {
+ snprintf(buf, sizeof(buf), "{[:%d}{:%s/%%s}{]:} ",
+ -width, name);
+ xo_emit(buf, cp);
+ } else {
+ snprintf(buf, sizeof(buf), "{[:%d}{:%s/%%-.*s}{]:} ",
+ -width, name);
+ xo_emit(buf, width, cp);
+ }
}
}
@@ -742,7 +824,7 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)
case AF_NETGRAPH:
{
strlcpy(workbuf, ((struct sockaddr_ng *)sa)->sg_data,
- sizeof(workbuf));
+ sizeof(workbuf));
cp = workbuf;
break;
}
@@ -798,7 +880,15 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags)
static void
p_flags(int f, const char *format)
{
- printf(format, fmt_flags(f));
+ struct bits *p;
+
+ xo_emit(format, fmt_flags(f));
+
+ xo_open_list("flags_pretty");
+ for (p = bits; p->b_mask; p++)
+ if (p->b_mask & f)
+ xo_emit("{le:flags_pretty/%s}", p->b_name);
+ xo_close_list("flags_pretty");
}
static const char *
@@ -816,7 +906,7 @@ fmt_flags(int f)
}
static void
-p_rtentry_kvm(struct rtentry *rt)
+p_rtentry_kvm(const char *name, struct rtentry *rt)
{
static struct ifnet ifnet, *lastif;
static char buffer[128];
@@ -830,18 +920,21 @@ p_rtentry_kvm(struct rtentry *rt)
bzero(&mask, sizeof(mask));
if (rt_mask(rt) && (sa = kgetsa(rt_mask(rt))))
bcopy(sa, &mask, sa->sa_len);
- p_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags, wid_dst);
- p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, wid_gw);
- snprintf(buffer, sizeof(buffer), "%%-%d.%ds ", wid_flags, wid_flags);
+
+ p_sockaddr("destination", &addr.u_sa, &mask.u_sa, rt->rt_flags,
+ wid_dst);
+ p_sockaddr("gateway", kgetsa(rt->rt_gateway), NULL, RTF_HOST, wid_gw);
+ snprintf(buffer, sizeof(buffer), "{[:-%d}{:flags/%%s}{]:}",
+ wid_flags);
p_flags(rt->rt_flags, buffer);
if (Wflag) {
- printf("%*ju ", wid_pksent,
+ xo_emit("{[:%d}{t:use/%ju}{]:} ", -wid_pksent,
(uintmax_t )kread_counter((u_long )rt->rt_pksent));
if (rt->rt_mtu != 0)
- printf("%*lu ", wid_mtu, rt->rt_mtu);
+ xo_emit("{t:mtu/%*lu} ", wid_mtu, rt->rt_mtu);
else
- printf("%*s ", wid_mtu, "");
+ xo_emit("{P:/%*s} ", wid_mtu, "");
}
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
@@ -852,18 +945,19 @@ p_rtentry_kvm(struct rtentry *rt)
strlcpy(prettyname, "---", sizeof(prettyname));
lastif = rt->rt_ifp;
}
- printf("%*.*s", wid_if, wid_if, prettyname);
+ xo_emit("{t:interface-name/%*.*s}", wid_if, wid_if, prettyname);
if (rt->rt_expire) {
time_t expire_time;
if ((expire_time =
rt->rt_expire - uptime.tv_sec) > 0)
- printf(" %*d", wid_expire, (int)expire_time);
+ xo_emit(" {:expire-time/%*d}",
+ wid_expire, (int)expire_time);
}
if (rt->rt_nodes[0].rn_dupedkey)
- printf(" =>");
+ xo_emit(" =>");
}
- putchar('\n');
+ xo_emit("\n");
}
char *
@@ -1022,7 +1116,7 @@ netname6(struct sockaddr_in6 *sa6, struct in6_addr *mask)
}
}
if (illegal)
- fprintf(stderr, "illegal prefixlen\n");
+ xo_error("illegal prefixlen\n");
}
else
masklen = 128;
@@ -1077,28 +1171,34 @@ rt_stats(void)
kresolve_list(rl);
if ((rtsaddr = rl[N_RTSTAT].n_value) == 0) {
- printf("rtstat: symbol not in namelist\n");
+ xo_emit("{W:rtstat: symbol not in namelist}\n");
return;
}
if ((rttaddr = rl[N_RTTRASH].n_value) == 0) {
- printf("rttrash: symbol not in namelist\n");
+ xo_emit("{W:rttrash: symbol not in namelist}\n");
return;
}
kread(rtsaddr, (char *)&rtstat, sizeof (rtstat));
kread(rttaddr, (char *)&rttrash, sizeof (rttrash));
- printf("routing:\n");
+ xo_emit("{T:routing}:\n");
#define p(f, m) if (rtstat.f || sflag <= 1) \
- printf(m, rtstat.f, plural(rtstat.f))
-
- p(rts_badredirect, "\t%hu bad routing redirect%s\n");
- p(rts_dynamic, "\t%hu dynamically created route%s\n");
- p(rts_newgateway, "\t%hu new gateway%s due to redirects\n");
- p(rts_unreach, "\t%hu destination%s found unreachable\n");
- p(rts_wildcard, "\t%hu use%s of a wildcard route\n");
+ xo_emit(m, rtstat.f, plural(rtstat.f))
+
+ p(rts_badredirect, "\t{:bad-redirects/%hu} "
+ "{N:/bad routing redirect%s}\n");
+ p(rts_dynamic, "\t{:dynamically-created/%hu} "
+ "{N:/dynamically created route%s}\n");
+ p(rts_newgateway, "\t{:new-gateways/%hu} "
+ "{N:/new gateway%s due to redirects}\n");
+ p(rts_unreach, "\t{:unreachable-destination/%hu} "
+ "{N:/destination%s found unreachable}\n");
+ p(rts_wildcard, "\t{:wildcard-uses/%hu} "
+ "{N:/use%s of a wildcard route}\n");
#undef p
if (rttrash || sflag <= 1)
- printf("\t%u route%s not in table but not freed\n",
+ xo_emit("\t{:unused-but-not-freed/%u} "
+ "{N:/route%s not in table but not freed}\n",
rttrash, plural(rttrash));
}
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
index a2ef7d568..cdbbc49 100644
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -58,9 +58,11 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include "netstat.h"
+#include <libxo/xo.h>
#ifdef SCTP
@@ -98,8 +100,8 @@ struct xladdr_entry {
LIST_HEAD(xraddr_list, xraddr_entry) xraddr_head;
struct xraddr_entry {
- struct xsctp_raddr *xraddr;
- LIST_ENTRY(xraddr_entry) xraddr_entries;
+ struct xsctp_raddr *xraddr;
+ LIST_ENTRY(xraddr_entry) xraddr_entries;
};
/*
@@ -192,12 +194,16 @@ inet6name(struct in6_addr *in6p)
#endif
static void
-sctp_print_address(union sctp_sockstore *address, int port, int num_port)
+sctp_print_address(const char *container, union sctp_sockstore *address,
+ int port, int num_port)
{
struct servent *sp = 0;
char line[80], *cp;
int width;
+ if (container)
+ xo_open_container(container);
+
switch (address->sa.sa_family) {
#ifdef INET
case AF_INET:
@@ -221,7 +227,14 @@ sctp_print_address(union sctp_sockstore *address, int port, int num_port)
else
sprintf(cp, "%d ", ntohs((u_short)port));
width = Wflag ? 45 : 22;
- printf("%-*.*s ", width, width, line);
+ xo_emit("{d:target/%-*.*s} ", width, width, line);
+
+ int alen = cp - line - 1, plen = strlen(cp) - 1;
+ xo_emit("{e:address/%*.*s}{e:port/%*.*s}", alen, alen, line, plen,
+ plen, cp);
+
+ if (container)
+ xo_close_container(container);
}
static int
@@ -297,7 +310,7 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
prev_xl = xl;
xl = malloc(sizeof(struct xladdr_entry));
if (xl == NULL) {
- warnx("malloc %lu bytes",
+ xo_warnx("malloc %lu bytes",
(u_long)sizeof(struct xladdr_entry));
goto out;
}
@@ -318,7 +331,7 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
prev_xr = xr;
xr = malloc(sizeof(struct xraddr_entry));
if (xr == NULL) {
- warnx("malloc %lu bytes",
+ xo_warnx("malloc %lu bytes",
(u_long)sizeof(struct xraddr_entry));
goto out;
}
@@ -333,26 +346,29 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
/*
* Let's print the address infos.
*/
+ xo_open_list("address");
xl = LIST_FIRST(&xladdr_head);
xr = LIST_FIRST(&xraddr_head);
x_max = (xl_total > xr_total) ? xl_total : xr_total;
for (i = 0; i < x_max; i++) {
+ xo_open_instance("address");
+
if (((*indent == 0) && i > 0) || *indent > 0)
- printf("%-12s ", " ");
+ xo_emit("{P:/%-12s} ", " ");
if (xl != NULL) {
- sctp_print_address(&(xl->xladdr->address),
+ sctp_print_address("local", &(xl->xladdr->address),
htons(xstcb->local_port), numeric_port);
} else {
if (Wflag) {
- printf("%-45s ", " ");
+ xo_emit("{P:/%-45s} ", " ");
} else {
- printf("%-22s ", " ");
+ xo_emit("{P:/%-22s} ", " ");
}
}
if (xr != NULL && !Lflag) {
- sctp_print_address(&(xr->xraddr->address),
+ sctp_print_address("remote", &(xr->xraddr->address),
htons(xstcb->remote_port), numeric_port);
}
@@ -365,7 +381,8 @@ sctp_process_tcb(struct xsctp_tcb *xstcb,
sctp_statesprint(xstcb->state);
if (i < x_max)
- putchar('\n');
+ xo_emit("\n");
+ xo_close_instance("address");
}
out:
@@ -404,23 +421,26 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
if (first) {
if (!Lflag) {
- printf("Active SCTP associations");
+ xo_emit("Active SCTP associations");
if (aflag)
- printf(" (including servers)");
+ xo_emit(" (including servers)");
} else
- printf("Current listen queue sizes (qlen/maxqlen)");
- putchar('\n');
+ xo_emit("Current listen queue sizes (qlen/maxqlen)");
+ xo_emit("\n");
if (Lflag)
- printf("%-6.6s %-5.5s %-8.8s %-22.22s\n",
+ xo_emit("{T:/%-6.6s} {T:/%-5.5s} {T:/%-8.8s} "
+ "{T:/%-22.22s}\n",
"Proto", "Type", "Listen", "Local Address");
else
if (Wflag)
- printf("%-6.6s %-5.5s %-45.45s %-45.45s %s\n",
+ xo_emit("{T:/%-6.6s} {T:/%-5.5s} {T:/%-45.45s} "
+ "{T:/%-45.45s} {T:/%s}\n",
"Proto", "Type",
"Local Address", "Foreign Address",
"(state)");
else
- printf("%-6.6s %-5.5s %-22.22s %-22.22s %s\n",
+ xo_emit("{T:/%-6.6s} {T:/%-5.5s} {T:/%-22.22s} "
+ "{T:/%-22.22s} {T:/%s}\n",
"Proto", "Type",
"Local Address", "Foreign Address",
"(state)");
@@ -450,27 +470,38 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
char buf1[9];
snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen);
- printf("%-6.6s %-5.5s ", pname, tname);
- printf("%-8.8s ", buf1);
+ xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
+ pname, tname);
+ xo_emit("{d:queues/%-8.8s}{e:queue-len/%hu}"
+ "{e:max-queue-len/%hu} ",
+ buf1, xinpcb->qlen, xinpcb->maxqlen);
}
offset_laddr = *offset;
process_closed = 0;
+
+ xo_open_list("local-address");
retry:
while (*offset < buflen) {
xladdr = (struct xsctp_laddr *)(buf + *offset);
*offset += sizeof(struct xsctp_laddr);
if (xladdr->last) {
if (aflag && !Lflag && (xladdr_total == 0) && process_closed) {
- printf("%-6.6s %-5.5s ", pname, tname);
+ xo_open_instance("local-address");
+
+ xo_emit("{:protocol/%-6.6s/%s} "
+ "{:type/%-5.5s/%s} ", pname, tname);
if (Wflag) {
- printf("%-91.91s CLOSED", " ");
+ xo_emit("{P:/%-91.91s/%s} "
+ "{:state/CLOSED}", " ");
} else {
- printf("%-45.45s CLOSED", " ");
+ xo_emit("{P:/%-45.45s/%s} "
+ "{:state/CLOSED}", " ");
}
+ xo_close_instance("local-address");
}
if (process_closed || is_listening) {
- putchar('\n');
+ xo_emit("\n");
}
break;
}
@@ -478,31 +509,39 @@ retry:
if (!Lflag && !is_listening && !process_closed)
continue;
+ xo_open_instance("local-address");
+
if (xladdr_total == 0) {
- printf("%-6.6s %-5.5s ", pname, tname);
+ xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
+ pname, tname);
} else {
- putchar('\n');
- printf((Lflag) ?
- "%-21.21s " : "%-12.12s ", " ");
+ xo_emit("\n");
+ xo_emit(Lflag ? "{P:/%-21.21s} " : "{P:/%-12.12s} ",
+ " ");
}
- sctp_print_address(&(xladdr->address),
+ sctp_print_address("local", &(xladdr->address),
htons(xinpcb->local_port), numeric_port);
if (aflag && !Lflag && xladdr_total == 0) {
if (Wflag) {
if (process_closed) {
- printf("%-45.45s CLOSED", " ");
+ xo_emit("{P:/%-45.45s} "
+ "{:state/CLOSED}", " ");
} else {
- printf("%-45.45s LISTEN", " ");
+ xo_emit("{P:/%-45.45s} "
+ "{:state:LISTEN}", " ");
}
} else {
if (process_closed) {
- printf("%-22.22s CLOSED", " ");
+ xo_emit("{P:/%-22.22s} "
+ "{:state/CLOSED}", " ");
} else {
- printf("%-22.22s LISTEN", " ");
+ xo_emit("{P:/%-22.22s} "
+ "{:state/LISTEN}", " ");
}
}
}
xladdr_total++;
+ xo_close_instance("local-address");
}
xstcb = (struct xsctp_tcb *)(buf + *offset);
@@ -513,12 +552,15 @@ retry:
goto retry;
}
while (xstcb->last == 0 && *offset < buflen) {
- printf("%-6.6s %-5.5s ", pname, tname);
+ xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
+ pname, tname);
sctp_process_tcb(xstcb, buf, buflen, offset, &indent);
indent++;
xstcb = (struct xsctp_tcb *)(buf + *offset);
*offset += sizeof(struct xsctp_tcb);
}
+
+ xo_close_list("local-address");
}
/*
@@ -540,15 +582,15 @@ sctp_protopr(u_long off __unused,
if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: %s", mibvar);
+ xo_warn("sysctl: %s", mibvar);
return;
}
if ((buf = malloc(len)) == 0) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return;
}
if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
- warn("sysctl: %s", mibvar);
+ xo_warn("sysctl: %s", mibvar);
free(buf);
return;
}
@@ -594,11 +636,11 @@ sctp_statesprint(uint32_t state)
idx = NETSTAT_SCTP_STATES_SHUTDOWN_PENDING;
break;
default:
- printf("UNKNOWN 0x%08x", state);
+ xo_emit("UNKNOWN {:state/0x%08x}", state);
return;
}
- printf("%s", sctpstates[idx]);
+ xo_emit("{:state/%s}", sctpstates[idx]);
}
/*
@@ -616,96 +658,160 @@ sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: net.inet.sctp.stats");
+ xo_warn("sysctl: net.inet.sctp.stats");
return;
}
} else
kread(off, &sctpstat, len);
- printf ("%s:\n", name);
+ xo_open_container(name);
+ xo_emit("{T:/%s}:\n", name);
#define p(f, m) if (sctpstat.f || sflag <= 1) \
- printf(m, (uintmax_t)sctpstat.f, plural(sctpstat.f))
+ xo_emit(m, (uintmax_t)sctpstat.f, plural(sctpstat.f))
#define p1a(f, m) if (sctpstat.f || sflag <= 1) \
- printf(m, (uintmax_t)sctpstat.f)
+ xo_emit(m, (uintmax_t)sctpstat.f)
/*
* input statistics
*/
- p(sctps_recvpackets, "\t%ju input packet%s\n");
- p(sctps_recvdatagrams, "\t\t%ju datagram%s\n");
- p(sctps_recvpktwithdata, "\t\t%ju packet%s that had data\n");
- p(sctps_recvsacks, "\t\t%ju input SACK chunk%s\n");
- p(sctps_recvdata, "\t\t%ju input DATA chunk%s\n");
- p(sctps_recvdupdata, "\t\t%ju duplicate DATA chunk%s\n");
- p(sctps_recvheartbeat, "\t\t%ju input HB chunk%s\n");
- p(sctps_recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n");
- p(sctps_recvecne, "\t\t%ju input ECNE chunk%s\n");
- p(sctps_recvauth, "\t\t%ju input AUTH chunk%s\n");
- p(sctps_recvauthmissing, "\t\t%ju chunk%s missing AUTH\n");
- p(sctps_recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n");
- p(sctps_recvivalkeyid, "\t\t%ju invalid secret id%s received\n");
- p1a(sctps_recvauthfailed, "\t\t%ju auth failed\n");
- p1a(sctps_recvexpress, "\t\t%ju fast path receives all one chunk\n");
- p1a(sctps_recvexpressm, "\t\t%ju fast path multi-part data\n");
+ p(sctps_recvpackets, "\t{:received-packets/%ju} "
+ "{N:/input packet%s}\n");
+ p(sctps_recvdatagrams, "\t\t{:received-datagrams/%ju} "
+ "{N:/datagram%s}\n");
+ p(sctps_recvpktwithdata, "\t\t{:received-with-data/%ju} "
+ "{N:/packet%s that had data}\n");
+ p(sctps_recvsacks, "\t\t{:received-sack-chunks/%ju} "
+ "{N:/input SACK chunk%s}\n");
+ p(sctps_recvdata, "\t\t{:received-data-chunks/%ju} "
+ "{N:/input DATA chunk%s}\n");
+ p(sctps_recvdupdata, "\t\t{:received-duplicate-data-chunks/%ju} "
+ "{N:/duplicate DATA chunk%s}\n");
+ p(sctps_recvheartbeat, "\t\t{:received-hb-chunks/%ju} "
+ "{N:/input HB chunk%s}\n");
+ p(sctps_recvheartbeatack, "\t\t{:received-hb-ack-chunks/%ju} "
+ "{N:/HB-ACK chunk%s}\n");
+ p(sctps_recvecne, "\t\t{:received-ecne-chunks/%ju} "
+ "{N:/input ECNE chunk%s}\n");
+ p(sctps_recvauth, "\t\t{:received-auth-chunks/%ju} "
+ "{N:/input AUTH chunk%s}\n");
+ p(sctps_recvauthmissing, "\t\t{:dropped-missing-auth/%ju} "
+ "{N:/chunk%s missing AUTH}\n");
+ p(sctps_recvivalhmacid, "\t\t{:dropped-invalid-hmac/%ju} "
+ "{N:/invalid HMAC id%s received}\n");
+ p(sctps_recvivalkeyid, "\t\t{:dropped-invalid-secret/%ju} "
+ "{N:/invalid secret id%s received}\n");
+ p1a(sctps_recvauthfailed, "\t\t{:dropped-auth-failed/%ju} "
+ "{N:/auth failed}\n");
+ p1a(sctps_recvexpress, "\t\t{:received-fast-path/%ju} "
+ "{N:/fast path receives all one chunk}\n");
+ p1a(sctps_recvexpressm, "\t\t{:receives-fast-path-multipart/%ju} "
+ "{N:/fast path multi-part data}\n");
/*
* output statistics
*/
- p(sctps_sendpackets, "\t%ju output packet%s\n");
- p(sctps_sendsacks, "\t\t%ju output SACK%s\n");
- p(sctps_senddata, "\t\t%ju output DATA chunk%s\n");
- p(sctps_sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n");
- p(sctps_sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n");
- p(sctps_sendmultfastretrans, "\t\t%ju FR'%s that happened more "
- "than once to same chunk\n");
- p(sctps_sendheartbeat, "\t\t%ju output HB chunk%s\n");
- p(sctps_sendecne, "\t\t%ju output ECNE chunk%s\n");
- p(sctps_sendauth, "\t\t%ju output AUTH chunk%s\n");
- p1a(sctps_senderrors, "\t\t%ju ip_output error counter\n");
+ p(sctps_sendpackets, "\t{:sent-packets/%ju} "
+ "{N:/output packet%s}\n");
+ p(sctps_sendsacks, "\t\t{:sent-sacks/%ju} "
+ "{N:/output SACK%s}\n");
+ p(sctps_senddata, "\t\t{:sent-data-chunks/%ju} "
+ "{N:/output DATA chunk%s}\n");
+ p(sctps_sendretransdata, "\t\t{:sent-retransmitted-data-chunks/%ju} "
+ "{N:/retransmitted DATA chunk%s}\n");
+ p(sctps_sendfastretrans, "\t\t"
+ "{:sent-fast-retransmitted-data-chunks/%ju} "
+ "{N:/fast retransmitted DATA chunk%s}\n");
+ p(sctps_sendmultfastretrans, "\t\t"
+ "{:sent-fast-retransmitted-data-chunk-multiple-times/%ju} "
+ "{N:/FR'%s that happened more than once to same chunk}\n");
+ p(sctps_sendheartbeat, "\t\t{:sent-hb-chunks/%ju} "
+ "{N:/output HB chunk%s}\n");
+ p(sctps_sendecne, "\t\t{:sent-ecne-chunks/%ju} "
+ "{N:/output ECNE chunk%s}\n");
+ p(sctps_sendauth, "\t\t{:sent-auth-chunks/%ju} "
+ "{N:/output AUTH chunk%s}\n");
+ p1a(sctps_senderrors, "\t\t{:send-errors/%ju} "
+ "{N:/ip_output error counter}\n");
/*
* PCKDROPREP statistics
*/
- printf("\tPacket drop statistics:\n");
- p1a(sctps_pdrpfmbox, "\t\t%ju from middle box\n");
- p1a(sctps_pdrpfehos, "\t\t%ju from end host\n");
- p1a(sctps_pdrpmbda, "\t\t%ju with data\n");
- p1a(sctps_pdrpmbct, "\t\t%ju non-data, non-endhost\n");
- p1a(sctps_pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n");
- p1a(sctps_pdrpcrupt, "\t\t%ju not enough for chunk header\n");
- p1a(sctps_pdrpnedat, "\t\t%ju not enough data to confirm\n");
- p1a(sctps_pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n");
- p1a(sctps_pdrptsnnf, "\t\t%ju failed to find TSN\n");
- p1a(sctps_pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n");
- p1a(sctps_pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n");
- p1a(sctps_pdrpdizrw, "\t\t%ju midbox confirms no space\n");
- p1a(sctps_pdrpbadd, "\t\t%ju data did not match TSN\n");
- p(sctps_pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n");
+ xo_emit("\t{T:Packet drop statistics}:\n");
+ xo_open_container("drop-statistics");
+ p1a(sctps_pdrpfmbox, "\t\t{:middle-box/%ju} "
+ "{N:/from middle box}\n");
+ p1a(sctps_pdrpfehos, "\t\t{:end-host/%ju} "
+ "{N:/from end host}\n");
+ p1a(sctps_pdrpmbda, "\t\t{:with-data/%ju} "
+ "{N:/with data}\n");
+ p1a(sctps_pdrpmbct, "\t\t{:non-data/%ju} "
+ "{N:/non-data, non-endhost}\n");
+ p1a(sctps_pdrpbwrpt, "\t\t{:non-endhost/%ju} "
+ "{N:/non-endhost, bandwidth rep only}\n");
+ p1a(sctps_pdrpcrupt, "\t\t{:short-header/%ju} "
+ "{N:/not enough for chunk header}\n");
+ p1a(sctps_pdrpnedat, "\t\t{:short-data/%ju} "
+ "{N:/not enough data to confirm}\n");
+ p1a(sctps_pdrppdbrk, "\t\t{:chunk-break/%ju} "
+ "{N:/where process_chunk_drop said break}\n");
+ p1a(sctps_pdrptsnnf, "\t\t{:tsn-not-found/%ju} "
+ "{N:/failed to find TSN}\n");
+ p1a(sctps_pdrpdnfnd, "\t\t{:reverse-tsn/%ju} "
+ "{N:/attempt reverse TSN lookup}\n");
+ p1a(sctps_pdrpdiwnp, "\t\t{:confirmed-zero-window/%ju} "
+ "{N:/e-host confirms zero-rwnd}\n");
+ p1a(sctps_pdrpdizrw, "\t\t{:middle-box-no-space/%ju} "
+ "{N:/midbox confirms no space}\n");
+ p1a(sctps_pdrpbadd, "\t\t{:bad-data/%ju} "
+ "{N:/data did not match TSN}\n");
+ p(sctps_pdrpmark, "\t\t{:tsn-marked-fast-retransmission/%ju} "
+ "{N:/TSN'%s marked for Fast Retran}\n");
+ xo_close_container("drop-statistics");
/*
* Timeouts
*/
- printf("\tTimeouts:\n");
- p(sctps_timoiterator, "\t\t%ju iterator timer%s fired\n");
- p(sctps_timodata, "\t\t%ju T3 data time out%s\n");
- p(sctps_timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n");
- p(sctps_timoinit, "\t\t%ju INIT timer%s fired\n");
- p(sctps_timosack, "\t\t%ju sack timer%s fired\n");
- p(sctps_timoshutdown, "\t\t%ju shutdown timer%s fired\n");
- p(sctps_timoheartbeat, "\t\t%ju heartbeat timer%s fired\n");
- p1a(sctps_timocookie, "\t\t%ju a cookie timeout fired\n");
- p1a(sctps_timosecret, "\t\t%ju an endpoint changed its cookie"
+ xo_emit("\t{T:Timeouts}:\n");
+ xo_open_container("timeouts");
+ p(sctps_timoiterator, "\t\t{:iterator/%ju} "
+ "{N:/iterator timer%s fired}\n");
+ p(sctps_timodata, "\t\t{:t3-data/%ju} "
+ "{N:/T3 data time out%s}\n");
+ p(sctps_timowindowprobe, "\t\t{:window-probe/%ju} "
+ "{N:/window probe (T3) timer%s fired}\n");
+ p(sctps_timoinit, "\t\t{:init-timer/%ju} "
+ "{N:/INIT timer%s fired}\n");
+ p(sctps_timosack, "\t\t{:sack-timer/%ju} "
+ "{N:/sack timer%s fired}\n");
+ p(sctps_timoshutdown, "\t\t{:shutdown-timer/%ju} "
+ "{N:/shutdown timer%s fired}\n");
+ p(sctps_timoheartbeat, "\t\t{:heartbeat-timer/%ju} "
+ "{N:/heartbeat timer%s fired}\n");
+ p1a(sctps_timocookie, "\t\t{:cookie-timer/%ju} "
+ "{N:/a cookie timeout fired}\n");
+ p1a(sctps_timosecret, "\t\t{:endpoint-changed-cookie/%ju} "
+ "{N:/an endpoint changed its cook}ie"
"secret\n");
- p(sctps_timopathmtu, "\t\t%ju PMTU timer%s fired\n");
- p(sctps_timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n");
- p(sctps_timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n");
- p(sctps_timostrmrst, "\t\t%ju stream reset timer%s fired\n");
- p(sctps_timoearlyfr, "\t\t%ju early FR timer%s fired\n");
- p1a(sctps_timoasconf, "\t\t%ju an asconf timer fired\n");
- p1a(sctps_timoautoclose, "\t\t%ju auto close timer fired\n");
- p(sctps_timoassockill, "\t\t%ju asoc free timer%s expired\n");
- p(sctps_timoinpkill, "\t\t%ju inp free timer%s expired\n");
+ p(sctps_timopathmtu, "\t\t{:pmtu-timer/%ju} "
+ "{N:/PMTU timer%s fired}\n");
+ p(sctps_timoshutdownack, "\t\t{:shutdown-timer/%ju} "
+ "{N:/shutdown ack timer%s fired}\n");
+ p(sctps_timoshutdownguard, "\t\t{:shutdown-guard-timer/%ju} "
+ "{N:/shutdown guard timer%s fired}\n");
+ p(sctps_timostrmrst, "\t\t{:stream-reset-timer/%ju} "
+ "{N:/stream reset timer%s fired}\n");
+ p(sctps_timoearlyfr, "\t\t{:early-fast-retransmission-timer/%ju} "
+ "{N:/early FR timer%s fired}\n");
+ p1a(sctps_timoasconf, "\t\t{:asconf-timer/%ju} "
+ "{N:/an asconf timer fired}\n");
+ p1a(sctps_timoautoclose, "\t\t{:auto-close-timer/%ju} "
+ "{N:/auto close timer fired}\n");
+ p(sctps_timoassockill, "\t\t{:asoc-free-timer/%ju} "
+ "{N:/asoc free timer%s expired}\n");
+ p(sctps_timoinpkill, "\t\t{:input-free-timer/%ju} "
+ "{N:/inp free timer%s expired}\n");
+ xo_close_container("timeouts");
#if 0
/*
@@ -727,60 +833,86 @@ sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
/*
* Others
*/
- p1a(sctps_hdrops, "\t%ju packet shorter than header\n");
- p1a(sctps_badsum, "\t%ju checksum error\n");
- p1a(sctps_noport, "\t%ju no endpoint for port\n");
- p1a(sctps_badvtag, "\t%ju bad v-tag\n");
- p1a(sctps_badsid, "\t%ju bad SID\n");
- p1a(sctps_nomem, "\t%ju no memory\n");
- p1a(sctps_fastretransinrtt, "\t%ju number of multiple FR in a RTT "
- "window\n");
+ p1a(sctps_hdrops, "\t{:dropped-too-short/%ju} "
+ "{N:/packet shorter than header}\n");
+ p1a(sctps_badsum, "\t{:dropped-bad-checksum/%ju} "
+ "{N:/checksum error}\n");
+ p1a(sctps_noport, "\t{:dropped-no-endpoint/%ju} "
+ "{N:/no endpoint for port}\n");
+ p1a(sctps_badvtag, "\t{:dropped-bad-v-tag/%ju} "
+ "{N:/bad v-tag}\n");
+ p1a(sctps_badsid, "\t{:dropped-bad-sid/%ju} "
+ "{N:/bad SID}\n");
+ p1a(sctps_nomem, "\t{:dropped-no-memory/%ju} "
+ "{N:/no memory}\n");
+ p1a(sctps_fastretransinrtt, "\t{:multiple-fast-retransmits-in-rtt/%ju} "
+ "{N:/number of multiple FR in a RT}T window\n");
#if 0
p(sctps_markedretrans, "\t%ju TODO:sctps_markedretrans\n");
#endif
- p1a(sctps_naglesent, "\t%ju RFC813 allowed sending\n");
- p1a(sctps_naglequeued, "\t%ju RFC813 does not allow sending\n");
- p1a(sctps_maxburstqueued, "\t%ju times max burst prohibited sending\n");
- p1a(sctps_ifnomemqueued, "\t%ju look ahead tells us no memory in "
- "interface\n");
- p(sctps_windowprobed, "\t%ju number%s of window probes sent\n");
- p(sctps_lowlevelerr, "\t%ju time%s an output error to clamp "
- "down on next user send\n");
- p(sctps_lowlevelerrusr, "\t%ju time%s sctp_senderrors were "
- "caused from a user\n");
- p(sctps_datadropchklmt, "\t%ju number of in data drop%s due to "
- "chunk limit reached\n");
- p(sctps_datadroprwnd, "\t%ju number of in data drop%s due to rwnd "
- "limit reached\n");
- p(sctps_ecnereducedcwnd, "\t%ju time%s a ECN reduced "
- "the cwnd\n");
- p1a(sctps_vtagexpress, "\t%ju used express lookup via vtag\n");
- p1a(sctps_vtagbogus, "\t%ju collision in express lookup\n");
- p(sctps_primary_randry, "\t%ju time%s the sender ran dry "
- "of user data on primary\n");
- p1a(sctps_cmt_randry, "\t%ju same for above\n");
- p(sctps_slowpath_sack, "\t%ju sack%s the slow way\n");
- p(sctps_wu_sacks_sent, "\t%ju window update only sack%s sent\n");
- p(sctps_sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n");
- p(sctps_sends_with_unord, "\t%ju unordered send%s\n");
- p(sctps_sends_with_eof, "\t%ju send%s with EOF flag set\n");
- p(sctps_sends_with_abort, "\t%ju send%s with ABORT flag set\n");
- p(sctps_protocol_drain_calls, "\t%ju time%s protocol drain called\n");
- p(sctps_protocol_drains_done, "\t%ju time%s we did a protocol "
- "drain\n");
- p(sctps_read_peeks, "\t%ju time%s recv was called with peek\n");
- p(sctps_cached_chk, "\t%ju cached chunk%s used\n");
- p1a(sctps_cached_strmoq, "\t%ju cached stream oq's used\n");
- p(sctps_left_abandon, "\t%ju unread message%s abandonded by close\n");
- p1a(sctps_send_burst_avoid, "\t%ju send burst avoidance, already "
- "max burst inflight to net\n");
- p1a(sctps_send_cwnd_avoid, "\t%ju send cwnd full avoidance, already "
- "max burst inflight to net\n");
- p(sctps_fwdtsn_map_over, "\t%ju number of map array over-run%s via "
- "fwd-tsn's\n");
+ p1a(sctps_naglesent, "\t{:rfc813-sent/%ju} "
+ "{N:/RFC813 allowed sending}\n");
+ p1a(sctps_naglequeued, "\t{:rfc813-queued/%ju} "
+ "{N:/RFC813 does not allow sending}\n");
+ p1a(sctps_maxburstqueued, "\t{:max-burst-queued/%ju} "
+ "{N:/times max burst prohibited sending}\n");
+ p1a(sctps_ifnomemqueued, "\t{:no-memory-in-interface/%ju} "
+ "{N:/look ahead tells us no memory in interface}\n");
+ p(sctps_windowprobed, "\t{:sent-window-probes/%ju} "
+ "{N:/number%s of window probes sent}\n");
+ p(sctps_lowlevelerr, "\t{:low-level-err/%ju} "
+ "{N:/time%s an output error to clamp down on next user send}\n");
+ p(sctps_lowlevelerrusr, "\t{:low-level-user-error/%ju} "
+ "{N:/time%s sctp_senderrors were caused from a user}\n");
+ p(sctps_datadropchklmt, "\t{:dropped-chunk-limit/%ju} "
+ "{N:/number of in data drop%s due to chunk limit reached}\n");
+ p(sctps_datadroprwnd, "\t{:dropped-rwnd-limit/%ju} "
+ "{N:/number of in data drop%s due to rwnd limit reached}\n");
+ p(sctps_ecnereducedcwnd, "\t{:ecn-reduced-cwnd/%ju} "
+ "{N:/time%s a ECN reduced the cwnd}\n");
+ p1a(sctps_vtagexpress, "\t{:v-tag-express-lookup/%ju} "
+ "{N:/used express lookup via vtag}\n");
+ p1a(sctps_vtagbogus, "\t{:v-tag-collision/%ju} "
+ "{N:/collision in express lookup}\n");
+ p(sctps_primary_randry, "\t{:sender-ran-dry/%ju} "
+ "{N:/time%s the sender ran dry of user data on primary}\n");
+ p1a(sctps_cmt_randry, "\t{:cmt-ran-dry/%ju} "
+ "{N:/same for above}\n");
+ p(sctps_slowpath_sack, "\t{:slow-path-sack/%ju} "
+ "{N:/sack%s the slow way}\n");
+ p(sctps_wu_sacks_sent, "\t{:sent-window-update-only-sack/%ju} "
+ "{N:/window update only sack%s sent}\n");
+ p(sctps_sends_with_flags, "\t{:sent-with-sinfo/%ju} "
+ "{N:/send%s with sinfo_flags !=0}\n");
+ p(sctps_sends_with_unord, "\t{:sent-with-unordered/%ju} "
+ "{N:/unordered send%s}\n");
+ p(sctps_sends_with_eof, "\t{:sent-with-eof/%ju} "
+ "{N:/send%s with EOF flag set}\n");
+ p(sctps_sends_with_abort, "\t{:sent-with-abort/%ju} "
+ "{N:/send%s with ABORT flag set}\n");
+ p(sctps_protocol_drain_calls, "\t{:protocol-drain-called/%ju} "
+ "{N:/time%s protocol drain called}\n");
+ p(sctps_protocol_drains_done, "\t{:protocol-drain/%ju} "
+ "{N:/time%s we did a protocol drain}\n");
+ p(sctps_read_peeks, "\t{:read-with-peek/%ju} "
+ "{N:/time%s recv was called with peek}\n");
+ p(sctps_cached_chk, "\t{:cached-chunks/%ju} "
+ "{N:/cached chunk%s used}\n");
+ p1a(sctps_cached_strmoq, "\t{:cached-output-queue-used/%ju} "
+ "{N:/cached stream oq's used}\n");
+ p(sctps_left_abandon, "\t{:messages-abandoned/%ju} "
+ "{N:/unread message%s abandonded by close}\n");
+ p1a(sctps_send_burst_avoid, "\t{:send-burst-avoidance/%ju} "
+ "{N:/send burst avoidance, already max burst inflight to net}\n");
+ p1a(sctps_send_cwnd_avoid, "\t{:send-cwnd-avoidance/%ju} "
+ "{N:/send cwnd full avoidance, already max burst inflight "
+ "to net}\n");
+ p(sctps_fwdtsn_map_over, "\t{:tsn-map-overruns/%ju} "
+ "{N:/number of map array over-run%s via fwd-tsn's}\n");
#undef p
#undef p1a
+ xo_close_container(name);
}
#endif /* SCTP */
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index a5cc037..a7503f5 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -57,8 +57,10 @@ __FBSDID("$FreeBSD$");
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <strings.h>
#include <kvm.h>
+#include <libxo/xo.h>
#include "netstat.h"
static void unixdomainpr(struct xunpcb *, struct xsocket *);
@@ -78,15 +80,15 @@ pcblist_sysctl(int type, char **bufp)
len = 0;
if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
if (errno != ENOENT)
- warn("sysctl: %s", mibvar);
+ xo_warn("sysctl: %s", mibvar);
return (-1);
}
if ((buf = malloc(len)) == 0) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return (-2);
}
if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
- warn("sysctl: %s", mibvar);
+ xo_warn("sysctl: %s", mibvar);
free(buf);
return (-2);
}
@@ -115,14 +117,14 @@ pcblist_kvm(u_long count_off, u_long gencnt_off, u_long head_off, char **bufp)
kread(count_off, &unp_count, sizeof(unp_count));
len = 2 * sizeof(xug) + (unp_count + unp_count / 8) * sizeof(xu);
if ((buf = malloc(len)) == 0) {
- warnx("malloc %lu bytes", (u_long)len);
+ xo_warnx("malloc %lu bytes", (u_long)len);
return (-2);
}
p = buf;
#define COPYOUT(obj, size) do { \
if (len < (size)) { \
- warnx("buffer size exceeded"); \
+ xo_warnx("buffer size exceeded"); \
goto fail; \
} \
bcopy((obj), p, (size)); \
@@ -190,7 +192,7 @@ fail:
void
unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
- u_long sphead_off)
+ u_long sphead_off, bool *first)
{
char *buf;
int ret, type;
@@ -228,26 +230,35 @@ unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
oxug = xug = (struct xunpgen *)buf;
for (xug = (struct xunpgen *)((char *)xug + xug->xug_len);
- xug->xug_len > sizeof(struct xunpgen);
- xug = (struct xunpgen *)((char *)xug + xug->xug_len)) {
+ xug->xug_len > sizeof(struct xunpgen);
+ xug = (struct xunpgen *)((char *)xug + xug->xug_len)) {
xunp = (struct xunpcb *)xug;
so = &xunp->xu_socket;
/* Ignore PCBs which were freed during copyout. */
if (xunp->xu_unp.unp_gencnt > oxug->xug_gen)
continue;
+ if (*first) {
+ xo_open_list("socket");
+ *first = false;
+ }
+ xo_open_instance("socket");
unixdomainpr(xunp, so);
+ xo_close_instance("socket");
}
if (xug != oxug && xug->xug_gen != oxug->xug_gen) {
if (oxug->xug_count > xug->xug_count) {
- printf("Some %s sockets may have been deleted.\n",
- socktype[type]);
+ xo_emit("Some {:type/%s} sockets may have "
+ "been {:action/deleted}.\n",
+ socktype[type]);
} else if (oxug->xug_count < xug->xug_count) {
- printf("Some %s sockets may have been created.\n",
- socktype[type]);
+ xo_emit("Some {:type/%s} sockets may have "
+ "been {:action/created}.\n",
+ socktype[type]);
} else {
- printf("Some %s sockets may have been created or deleted",
- socktype[type]);
+ xo_emit("Some {:type/%s} sockets may have "
+ "been {:action/created or deleted}",
+ socktype[type]);
}
}
free(buf);
@@ -261,6 +272,25 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
struct sockaddr_un *sa;
static int first = 1;
char buf1[15];
+ static const char *titles[2] = {
+ "{T:/%-8.8s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%8.8s} "
+ "{T:/%8.8s} {T:/%8.8s} {T:/%8.8s} {T:Addr}\n",
+ "{T:/%-16.16s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%16.16s} "
+ "{T:/%16.16s} {T:/%16.16s} {T:/%16.16s} {T:Addr}\n"
+ };
+ static const char *format[2] = {
+ "{q:address/%8lx} {t:type/%-6.6s} "
+ "{:receive-bytes-waiting/%6u} "
+ "{:send-bytes-waiting/%6u} "
+ "{q:vnode/%8lx} {q:connection/%8lx} "
+ "{q:first-reference/%8lx} {q:next-reference/%8lx}",
+ "{q:address/%16lx} {t:type/%-6.6s} "
+ "{:receive-bytes-waiting/%6u} "
+ "{:send-bytes-waiting/%6u} "
+ "{q:vnode/%16lx} {q:connection/%16lx} "
+ "{q:first-reference/%16lx} {q:next-reference/%16lx}"
+ };
+ int fmt = (sizeof(void *) == 8) ? 1 : 0;
unp = &xunp->xu_unp;
if (unp->unp_addr)
@@ -269,9 +299,8 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
sa = (struct sockaddr_un *)0;
if (first && !Lflag) {
- printf("Active UNIX domain sockets\n");
- printf(
-"%-8.8s %-6.6s %-6.6s %-6.6s %8.8s %8.8s %8.8s %8.8s Addr\n",
+ xo_emit("{T:Active UNIX domain sockets}\n");
+ xo_emit(titles[fmt],
"Address", "Type", "Recv-Q", "Send-Q",
"Inode", "Conn", "Refs", "Nextref");
first = 0;
@@ -283,9 +312,11 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
if (Lflag) {
snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
so->so_incqlen, so->so_qlimit);
- printf("unix %-14.14s", buf1);
+ xo_emit("unix {d:socket/%-14.14s}{e:queue-length/%d}"
+ "{e:incomplete-queue-length/%d}{e:queue-limit/%d}",
+ buf1, so->so_qlen, so->so_incqlen, so->so_qlimit);
} else {
- printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
+ xo_emit(format[fmt],
(long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
so->so_snd.sb_cc, (long)unp->unp_vnode,
(long)unp->unp_conn,
@@ -293,8 +324,8 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
(long)LIST_NEXT(unp, unp_reflink));
}
if (sa)
- printf(" %.*s",
+ xo_emit(" {:path/%.*s}",
(int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)),
sa->sun_path);
- putchar('\n');
+ xo_emit("\n");
}
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 20b9fe0..30d843d 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -94,8 +94,6 @@ SUBDIR= adduser \
watchdogd \
zic
-SUBDIR:= ${SUBDIR:Nifmcstat}
-
# NB: keep these sorted by MK_* knobs
.if ${MK_ACCT} != "no"
diff --git a/usr.sbin/ifmcstat/Makefile b/usr.sbin/ifmcstat/Makefile
index 20de277..adf1304 100644
--- a/usr.sbin/ifmcstat/Makefile
+++ b/usr.sbin/ifmcstat/Makefile
@@ -15,9 +15,4 @@ WARNS?= 2
CFLAGS+=-DINET6
.endif
-.if ${MK_KVM_SUPPORT} != "no"
-CFLAGS+=-DWITH_KVM
-LIBADD= kvm
-.endif
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/ifmcstat/ifmcstat.c b/usr.sbin/ifmcstat/ifmcstat.c
index 9f51877..d3798e3 100644
--- a/usr.sbin/ifmcstat/ifmcstat.c
+++ b/usr.sbin/ifmcstat/ifmcstat.c
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
#include <sys/tree.h>
#include <net/if.h>
-#define _WANT_IFADDR
#include <net/if_var.h>
#include <net/if_types.h>
#include <net/if_dl.h>
@@ -52,20 +51,12 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/igmp.h>
-#define KERNEL
-# include <netinet/if_ether.h>
-#undef KERNEL
-#define _KERNEL
-#define SYSCTL_DECL(x)
-# include <netinet/igmp_var.h>
-#undef SYSCTL_DECL
-#undef _KERNEL
+#include <netinet/if_ether.h>
+#include <netinet/igmp_var.h>
#ifdef INET6
#include <netinet/icmp6.h>
-#define _KERNEL
-# include <netinet6/mld6_var.h>
-#undef _KERNEL
+#include <netinet6/mld6_var.h>
#endif /* INET6 */
#include <arpa/inet.h>
@@ -82,14 +73,23 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <kvm.h>
#include <limits.h>
#include <ifaddrs.h>
-#include <nlist.h>
#include <sysexits.h>
#include <unistd.h>
-/* XXX: This file currently assumes INET and KVM support in the base system. */
+#ifdef KVM
+/*
+ * Currently the KVM build is broken. To be fixed it requires uncovering
+ * large amount of _KERNEL code in include files, and it is also very
+ * tentative to internal kernel ABI changes. If anyone wishes to restore
+ * it, please move it out of src/usr.sbin to src/tools/tools.
+ */
+#include <kvm.h>
+#include <nlist.h>
+#endif
+
+/* XXX: This file currently assumes INET support in the base system. */
#ifndef INET
#define INET
#endif
diff --git a/usr.sbin/jls/jls.8 b/usr.sbin/jls/jls.8
index 3137654..15a80d4 100644
--- a/usr.sbin/jls/jls.8
+++ b/usr.sbin/jls/jls.8
@@ -92,7 +92,8 @@ skipping read-only and unused parameters.
Implies
.Fl nq .
.It Fl v
-Print a multiple-line summary per jail, with the following parameters:
+Extend the standard display with a multiple-line summary per jail,
+containing the following parameters:
jail identifier (jid), hostname (host.hostname), path (path),
jail name (name), jail state (dying), cpuset ID (cpuset),
IP address(es) (ip4.addr and ip6.addr).
diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index ce07100..b1e28fb 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -78,7 +78,7 @@ static void quoted_print(char *str);
int
main(int argc, char **argv)
{
- char *dot, *ep, *jname;
+ char *dot, *ep, *jname, *pname;
int c, i, jflags, jid, lastjid, pflags, spc;
jname = NULL;
@@ -166,20 +166,23 @@ main(int argc, char **argv)
JP_USER);
add_param("path", NULL, (size_t)0, NULL, JP_USER);
}
- } else
+ } else {
+ pflags &= ~PRINT_VERBOSE;
while (optind < argc)
add_param(argv[optind++], NULL, (size_t)0, NULL,
JP_USER);
+ }
if (pflags & PRINT_SKIP) {
/* Check for parameters with jailsys parents. */
for (i = 0; i < nparams; i++) {
if ((params[i].jp_flags & JP_USER) &&
(dot = strchr(params[i].jp_name, '.'))) {
- *dot = 0;
- param_parent[i] = add_param(params[i].jp_name,
+ pname = alloca((dot - params[i].jp_name) + 1);
+ strlcpy(pname, params[i].jp_name,
+ (dot - params[i].jp_name) + 1);
+ param_parent[i] = add_param(pname,
NULL, (size_t)0, NULL, JP_OPT);
- *dot = '.';
}
}
}
@@ -291,10 +294,8 @@ add_param(const char *name, void *value, size_t valuelen,
param->jp_flags |= flags;
return param - params;
}
- if (jailparam_init(param, name) < 0)
- errx(1, "%s", jail_errmsg);
- param->jp_flags = flags;
- if ((value != NULL ? jailparam_import_raw(param, value, valuelen)
+ if (jailparam_init(param, name) < 0 ||
+ (value != NULL ? jailparam_import_raw(param, value, valuelen)
: jailparam_import(param, value)) < 0) {
if (flags & JP_OPT) {
nparams--;
@@ -302,6 +303,7 @@ add_param(const char *name, void *value, size_t valuelen,
}
errx(1, "%s", jail_errmsg);
}
+ param->jp_flags = flags;
return param - params;
}
diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c
index b3585d0..c1e2acd 100644
--- a/usr.sbin/pmccontrol/pmccontrol.c
+++ b/usr.sbin/pmccontrol/pmccontrol.c
@@ -147,11 +147,9 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list)
if (npmc == 0)
errx(EX_CONFIG, "No PMCs found");
- if ((map = malloc(npmc * ncpu)) == NULL)
+ if ((map = calloc(npmc, ncpu)) == NULL)
err(EX_SOFTWARE, "Out of memory");
- (void) memset(map, PMCC_OP_IGNORE, npmc*ncpu);
-
error = 0;
STAILQ_FOREACH(np, op_list, op_next) {
OpenPOWER on IntegriCloud