For RTL8211B or later PHYs, enable crossover detection and
auto-correction. This change makes re(4) establish a link with
a system using non-crossover UTP cable.

Tested by:	Michael BlackHeart < amdmiek <> gmail dot com >


git-svn-id: svn://svn.freebsd.org/base/head@248542 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix the EDMA CABQ handling - for now, the CABQ takes a descriptor chain
like the legacy chips expect.


git-svn-id: svn://svn.freebsd.org/base/head@248543 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Pull in r177252 from upstream clang trunk:

 Make sure to use same EABI version for external assembler as for
 integrated as.

This allows us to use gcc on a world built with clang on ARM.


git-svn-id: svn://svn.freebsd.org/base/head@248548 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix the logic inversion in the r248512.

Noted by:	mckay


git-svn-id: svn://svn.freebsd.org/base/head@248550 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add ipfw support for setting/matching DiffServ codepoints (DSCP).

Setting DSCP support is done via O_SETDSCP which works for both
IPv4 and IPv6 packets. Fast checksum recalculation (RFC 1624) is done for IPv4.
Dscp can be specified by name (AFXY, CSX, BE, EF), by value
(0..63) or via tablearg.

Matching DSCP is done via another opcode (O_DSCP) which accepts several
classes at once (af11,af22,be). Classes are stored in bitmask (2 u32 words).

Many people made their variants of this patch, the ones I'm aware of are
(in alphabetic order):

Dmitrii Tejblum
Marcelo Araujo
Roman Bogorodskiy (novel)
Sergey Matveichuk (sem)
Sergey Ryabin

PR:		kern/102471, kern/121122
MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@248552 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Remove unused variable.


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


git-svn-id: svn://svn.freebsd.org/base/head@248554 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Integrate Efika MX project back to home.

Sponsored by:	The FreeBSD Foundation


git-svn-id: svn://svn.freebsd.org/base/head@248557 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
When renaming a directory from one parent directory to another,
we need to call ufs_checkpath() to walk from our new location to
the root of the filesystem to ensure that we do not encounter
ourselves along the way. Until now, we accomplished this by reading
the ".." entries of each directory in our path until we reached
the root (or encountered an error). This change tries to avoid the
I/O of reading the ".." entries by first looking them up in the
name cache and only doing the I/O when the name cache lookup fails.

Reviewed by: kib
Tested by:   Peter Holm
MFC after:   4 weeks


git-svn-id: svn://svn.freebsd.org/base/head@248561 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
When the journaled FFS volume is suspended due to the journal space
becoming too low, the softdep flush thread processes the workitems,
which frees the space in journal, and then unsuspends the fs.  The
softdep_flush() and other workitem processing functions busy the
filesystem before iterating over the worklist, to prevent the parallel
unmount from freeing the mount data. The vfs_busy() is called with
MBF_NOWAIT flag.

Now, if the unmount is already started and the filesystem is suspended
due to low journal space, the journal is never flushed and filesystem
is never unsuspended, because vfs_busy(MBF_NOWAIT) call cannot succeed
for the unmounting fs, and softdep_flush() does not process the
workitems. Unmount needs to write metadata, where it hangs in the
"suspfs" state.

Move the vn_start_write() call in the dounmount() before setting the
MNTK_UNMOUNT flag. This practically ensures that softdep_flush()
processed the pending journal writes by making dounmount() wait for
the lift of the suspension.

Sponsored by:	The FreeBSD Foundation
Reported and tested by:	pho
MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@248562 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
In bufwrite(), a dirty buffer is moved to the clean queue before the
bufobj counter of the writes in progress is incremented.  Other thread
inspecting the bufobj would consider it clean.

For the regular vnodes, the vnode lock is typically held both by the
thread performing the bufwrite() and an other thread doing syncing,
which prevents the situation.  On the other hand, writes to the VCHR
vnodes are done without holding vnode lock.

Increment the write ref counter for the buffer object before calling
bundirty().

Sponsored by:	The FreeBSD Foundation
Tested by:	pho
MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@248563 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Set WARNS=3 so this actually compiles.


git-svn-id: svn://svn.freebsd.org/base/head@248564 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add new USB ID.

PR:		usb/177173
MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@248566 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Do not call vnode_pager_setsize() while a NFS node mutex is
locked. vnode_pager_setsize() might sleep waiting for the page after
EOF be unbusied.

Call vnode_pager_setsize() both for the regular and directory vnodes.

Reported by:	mich
Reviewed by:	rmacklem
Discussed with:	avg, jhb
MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@248567 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Assert that transient mapping of the bio is only done when unmapped
buffers are allowed.

Sponsored by:	The FreeBSD Foundation


git-svn-id: svn://svn.freebsd.org/base/head@248568 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Only size and create the bio_transient_map when unmapped buffers are
enabled.  Now, disabling the unmapped buffers should result in the
kernel memory map identical to pre-r248550.

Sponsored by:	The FreeBSD Foundation


git-svn-id: svn://svn.freebsd.org/base/head@248569 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add NGM_NAT_LIBALIAS_INFO command, that reports internal stats
of libalias instance. To be used in the mpd5 daemon.

Submitted by:	Dmitry Luhtionov <dmitryluhtionov gmail.com>


git-svn-id: svn://svn.freebsd.org/base/head@248570 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Merge libzfs_core branch:
  includes MFV 238590, 238592, 247580

MFV 238590, 238592:
  In the first zfs ioctl restructuring phase, the libzfs_core library was
  introduced. It is a new thin library that wraps around kernel ioctl's.
  The idea is to provide a forward-compatible way of dealing with new
  features. Arguments are passed in nvlists and not random zfs_cmd fields,
  new-style ioctls are logged to pool history using a new method of
  history logging.

  http://blog.delphix.com/matt/2012/01/17/the-future-of-libzfs/

MFV 247580 [1]:
  To address issues of several deadlocks and race conditions the locking
  code around dsl_dataset was rewritten and the interface to synctasks
  was changed.

User-Visible Changes:
  "zfs snapshot" can create more arbitrary snapshots at once (atomically)
  "zfs destroy" destroys multiple snapshots at once
  "zfs recv" has improved performance

Backward Compatibility:
  I have extended the compatibility layer to support full backward
  compatibility by remapping or rewriting the responsible ioctl arguments.
  Old utilities are fully supported by the new kernel module.

Forward Compatibility:
  New utilities work with old kernels with the following restrictions:
    - creating, destroying, holding and releasing of multiple snapshots
      at once is not supported, this includes recursive (-r) commands

Illumos ZFS issues:
  2882 implement libzfs_core
  2900 "zfs snapshot" should be able to create multiple,
       arbitrary snapshots at once
  3464 zfs synctask code needs restructuring

References:
  https://www.illumos.org/issues/2882
  https://www.illumos.org/issues/2900
  https://www.illumos.org/issues/3464 [1]

MFC after:	1 month
Sponsored by:	Hybrid Logic Inc. [1]


git-svn-id: svn://svn.freebsd.org/base/head@248571 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add TRIM support for L2ARC.

This adds TRIM support to cache vdevs. When ARC buffers are removed
from the L2ARC in arc_hdr_destroy(), arc_release() or l2arc_evict(),
the size previously occupied by the buffer gets scheduled for TRIMming.
As always, actual TRIMs are only issued to the L2ARC after
txg_trim_limit.

Reviewed by:	pjd (mentor)
Approved by:	pjd (mentor)
Obtained from:	https://github.com/dechamps/zfs/commit/31aae373994fd112256607edba7de2359da3e9dc
MFC after:	2 weeks


git-svn-id: svn://svn.freebsd.org/base/head@248572 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Don't register repair writes in the trim map.

The trim map inflight writes tree assumes non-conflicting writes, i.e.
that there will never be two simultaneous write I/Os to the same range
on the same vdev. This seemed like a sane assumption; however, in
actual testing, it appears that repair I/Os can very well conflict
with "normal" writes.

I'm not quite sure if these conflicting writes are supposed to happen
or not, but in the mean time, let's ignore repair writes for now. This
should be safe considering that, by definition, we never repair blocks
that are freed.

Reviewed by:	pjd (mentor)
Approved by:	pjd (mentor)
Obtained from:	Source: https://github.com/dechamps/zfs/commit/6a3cebaf7c5fcc92007280b5d403c15d0e61dfe3


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