g_disk_flushcache definitely should not be traced under G_T_TOPOLOGY

... use G_T_BIO instead

MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@240629 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add missing break


git-svn-id: svn://svn.freebsd.org/base/head@240630 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
zfs: allow both DEBUG and ZFS_DEBUG to be defined on command line

Discussed with:	pjd
MFC after:	10 days


git-svn-id: svn://svn.freebsd.org/base/head@240631 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
zfs: correctly calculate dn_bonuslen for saving SAs to disk

Since all attribute values start at 8-byte aligned boundary, we would
previously incorrectly calculate dn_bonuslen if any attribute but the
last had a variable-length value with length not multiple of 8.

Reported by:	Nicolas Rachinsky <fbsd-mas-0@ml.turing-complete.org>
Tested by:	Nicolas Rachinsky <fbsd-mas-0@ml.turing-complete.org>
Reviewed by:	Matthew Ahrens <mahrens@delphix.com> (for upstream)
MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@240632 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
mdoc: remove superfluous paragraph macro.


git-svn-id: svn://svn.freebsd.org/base/head@240633 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
acpi_cpu: explicitly notify userland about c-state changes

... after they are committed.
A notification is sent per CPU.

Reviewed by:	imp
MFC after:	3 weeks


git-svn-id: svn://svn.freebsd.org/base/head@240634 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
loader/i386: replace ugly inb/outb re-implementations with cpufunc.h

Use of __builtin_constant_p in a function that is only called via
a pointer is a good example of how out-of-date it was.

Suggested by:	bde
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@240637 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix DIOCNATLOOK: zero key padding before performing lookup.


git-svn-id: svn://svn.freebsd.org/base/head@240638 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Implement my first cut at filtered frames in aggregation sessions.

The hardware can optionally "filter" frames if successive transmissions
to a given node (ie, "entry in the keycache") fail.  That way the hardware
can implement a kind of early abort of all the other frames queued to
that destination, rather than simply trying to TX each frame to that
destination (and failing.)

The background:

* If a frame comes back as being filtered, the hardware didn't try to
  TX it (or it was outside the TX burst opportunity.) So, take it as a hint
  that some (but not all, see below) frames to the destination may be
  filtered.

* If the CLRDMASK bit is set in a TX descriptor, the "filter to this
  destination" bit in the keycache entry is cleared and TX to that host
  will be unconditionally retried.

* Right now everything has the CLRDMASK bit set, so filtered frames
  tend to be aggregates and frames that fall outside of the WME burst
  window. It was a bit worse in the past as I had messed up the TX
  flags and CLRDMASK wasn't being set on aggregate frames.

The annoying bits:

* It's easy (ish) to do for aggregate session frames - firstly, they
  can be retried in any order as long as they're within the BAW, and
  there's already a bunch of infrastructure tracking how many frames
  the TID has queued to the hardware (tid->hwq_depth.) However, for
  frames that bypassed the software queue, hwq_depth doesn't get
  incremented. I'll fix that in a subsequent commit.

* For non-aggregate session frames, the only retries that can occur
  are ones for sequence numbers that hvaen't successfully been TXed yet.
  Since there's no re-ordering going on in non-aggregate sessions, if any
  subsequent seqno frames make it out, any filtered frames before that
  seqno need to be dropped.

  Hence why this initially is just for aggregate session frames.

* Since there may be intermediary frames to the destination that
  have CLRDMASK set - for example, any directly dispatched management
  frames to that destination - it's possible that there will be some
  filtered frames followed up by some non filtered frames.  Thus,
  it can't be assumed that once you see a filtered frame for the given
  destination node, all subsequent frames for all TIDs will be filtered.

Ok, with that in mind:

* Create a per-TID filtered frame queue for frames that the hardware
  returns as filtered.

* Track filtered frames per-tid, rather than per-node.  It just makes
  the locking much easier.

* When a filtered frame appears in the completion function, the node
  transitions to "filtered", and all subsequent completed error frames
  (filtered or otherwise) are put on the filtered frame queue.  The TID
  is paused once (during the transition from non-filtered to filtered).

* If a filtered frame retry count exceeds SWMAX_RETRIES, a BAR should be
  sent.

* Once all the frames queued to the hardware for the given filtered frame
  TID, transition back from filtered frame to non-filtered frame, which
  means pre-pending all the filtered frames onto the head of the software
  queue, clearing the filtered frame state and unpausing the TID.

Things get quite hairy around handling completion (aggr, non-aggr, norm,
direct-dispatched frames to a hardware queue); whether it's an "error",
"cleanup" or "BAR" state as well as filtered, which order to do things
in (eg do filtered BEFORE checking for BAR, as the filter completion
may be needed to actually transmit a BAR frame.)

This work has definitely reminded me that I have to tidy up all the locking
and remove some of the ridiculous lock/unlock/lock/unlock going on in the
completion functions.

It's also reminded me that I should really split out TID versus hardware TXQ
locking, even if the underlying locking is still the destination hardware TXQ.

Finally, this is all pre-requisite for working on AP mode power save support
(PS-POLL, uAPSD) as well as improving performance to misbehaving nodes (as
they can transition into filter mode, stopping any TX until everything has
caught up.)

Finally (ish) - this should also be done for non-aggregate sessions as
there are still plenty of laptops and mobile devices that don't speak
802.11n but do wish for stable, useful power save AP support where packets
aren't simply dropped.  This requires software retransmission for
non-aggregate sessions to be implemented, which includes the caveats I've
mentioned above.

Finally finally - this doesn't yet do anything about the CLRDMASK bit in the
TX descriptor.  That's still unconditionally set to 1.  I'll debug the
current work (mostly ensuring I haven't busted up the hairy transitions
between BAR, filtered, error (all frames in an aggregate failing) and
cleanup (when transitioning from aggregation -> non-aggregation.))

Finally finally finally - this is all original work by yours truely, rather
than ported from the Atheros internal driver codebase or Linux ath9k.

Tested:
 * AR9280, AR5416 in STA mode
 * AR9280, AR9130 in hostap mode
 * Lots and lots of iperf testing in very marginal and non-marginal conditions,
   complete with inducing filtered frames + BAR TX conditions.


git-svn-id: svn://svn.freebsd.org/base/head@240639 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
- Add $FreeBSD$ to allow modifications to this file.
- Move $OpenBSD$ to a more standard place.


git-svn-id: svn://svn.freebsd.org/base/head@240640 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Make ruleset anchors in pf(4) reentrant. We've got two problems here:

1) Ruleset parser uses a global variable for anchor stack.
2) When processing a wildcard anchor, matching anchors are marked.

To fix the first one:

o Allocate anchor processing stack on stack. To make this allocation
  as small as possible, following measures taken:
  - Maximum stack size reduced from 64 to 32.
  - The struct pf_anchor_stackframe trimmed by one pointer - parent.
    We can always obtain the parent via the rule pointer.
  - When pf_test_rule() calls pf_get_translation(), the former lends
    its stack to the latter, to avoid recursive allocation 32 entries.

The second one appeared more tricky. The code, that marks anchors was
added in OpenBSD rev. 1.516 of pf.c. According to commit log, the idea
is to enable the "quick" keyword on an anchor rule. The feature isn't
documented anywhere. The most obscure part of the 1.516 was that code
examines the "match" mark on a just processed child, which couldn't be
put here by current frame. Since this wasn't documented even in the
commit message and functionality of this is not clear to me, I decided
to drop this examination for now. The rest of 1.516 is redone in a
thread safe manner - the mark isn't put on the anchor itself, but on
current stack frame. To avoid growing stack frame, we utilize LSB
from the rule pointer, relying on kernel malloc(9) returning pointer
aligned addresses.

Discussed with:		dhartmei


git-svn-id: svn://svn.freebsd.org/base/head@240641 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Provide kernel compile time option to make pf(4) default rule to drop.

This is important to secure a small timeframe at boot time, when
network is already configured, but pf(4) is not yet.

PR:		kern/171622
Submitted by:	Olivier Cochard-LabbИ <olivier cochard.me>


git-svn-id: svn://svn.freebsd.org/base/head@240642 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix build, pass the pointy hat please.


git-svn-id: svn://svn.freebsd.org/base/head@240644 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
- Add 'dsiz' and 'ssiz' keywords to show data and stack size respectively.

Approved by:	kib (mentor)
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@240645 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Do more than r236298 did in the projects/pf branch: use M_NOWAIT in
altq_add() and its descendants. Currently altq(4) in FreeBSD is configured
via pf(4) ioctls, which can't configure altq(4) w/o holding locks.
Fortunately, altq(4) code in spife of using M_WAITOK is ready to receive
NULL from malloc(9), so change is mostly mechanical. While here, utilize
M_ZERO instead of bzero().

A large redesign needed to achieve M_WAITOK usage when configuring altq(4).
Or an alternative (not pf(4)) configuration interface should be implemented.

Reported by:	pluknet


git-svn-id: svn://svn.freebsd.org/base/head@240646 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
- Bump date.

Submitted by:	pluknet
Approved by:	kib (mentor)
X-MFC-With:	r240645


git-svn-id: svn://svn.freebsd.org/base/head@240649 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
hwpmc amd_pcpu_fini: fix a bug in code locked under DEBUG

MFC after:	16 days


git-svn-id: svn://svn.freebsd.org/base/head@240650 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix panics on attempt to dereference uninitizlized pointer, returned via
'path' argument of ofw_parsedev() if devspec refers raw device with no path.

For example, `ls /pci@1f,0/ide@d/disk@0,0:a/` works fine, while
`ls /pci@1f,0/ide@d/disk@0,0:a` panicked before this change.


git-svn-id: svn://svn.freebsd.org/base/head@240655 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix grammar in the portion about FIBs.  Also, cross-reference
setfib(2) instead of setfib(1) for the 16-FIB limit.

PR:		docs/157452
Approved by:	hrs (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@240656 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add __aligned(4) to NVMe defined data structures.

This fixes issue in nvmecontrol(8), where clang throws a cast-align
warning when casting a __packed structure pointer to a uint32_t
pointer as part of printing raw hex output.

Reported by: dhw


git-svn-id: svn://svn.freebsd.org/base/head@240671 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f