MFC 219399:
When constructing a new cpuset, apply the parent cpuset's mask to the new
set's mask rather than the root mask.  This was causing the root mask to
be modified incorrectly.
MFC 219460: Remove now-obsolete comment.
MFC 219574:
- Add example of using 'scan' for wireless networks, similarly to
  OpenBSD's ifconfig(8).
- wlan0 isn't available on 7.x, so substitute ath0 for wlan0 in the
  example.

PR:		151952
MFC 219723:
- Formatting fix.
MFC r219525: amd64/NOTES: use a greater number in KSTACK_PAGES example
MFC r218816:

Add a helper script that detects which partition we are on and update the
other.

Obtained from:	FreeNAS
Sponsored by:	iXsystems, Inc.
MFC 219805:
- Use 'list scan' in favor of 'scan', as 'scan' has a different purpose.
MFC 219834:
Bump date from previous commit.
MFH r219209: Unbreak .Aq for non-ASCII output like -Tps or -Tutf8.

PR:             gnu/154822
Submitted by:   Dominic Fandrey <kamikaze@bsdforen.de>
MFC r218825.  [The implementation change to kdb_sysctl_available()
cannot be MFC'd as it requires a non-MFCable change (adding drains to
sbuf)].

Modify kdb_trap() so that it re-calls the dbbe_trap function as long as
the debugger back-end has changed.  This means that switching from ddb
to gdb no longer requires a "step" which can be dangerous on an
already-crashed kernel.

Also add a capability to get from the gdb back-end back to ddb, by
typing ^C in the console window.

While here, simplify kdb_sysctl_available() by using
sbuf_new_for_sysctl(), and use strlcpy() instead of strncpy() since the
strlcpy semantic is desired.
MFC r192908 (introduced before the stable/8 split from CURRENT):

fail(9) support:

Add support for kernel fault injection using KFAIL_POINT_* macros and
fail_point_* infrastructure. Add example fail point in vfs_bio.c to
simulate VM buf pressure.

MFC r192978:

Fix style/grammar issues in fail(9) man page.

MFC r216616:

Move the fail_point_entry definition from fail.h to kern_fail.c, which
allows putting the enumeration constants of fail point types with the
text string that matches them.

MFC r216620:

Initialize fp_location for explicitly managed fail points, and push
the parentheses around the location for simple fail points into the
location string.  This makes the print on fail point set more
consistent between the two versions.

Also fix up fail.h a little for style(9): only use one of sys/param.h
and sys/types.h, and use the existing __XSTRING() macro instead of
rolling our own.  Also fix up a few tabs on changed and nearby lines.

Lastly, since KFAIL_POINT_{BEGIN,END} are not meant for use outside
this file, just eliminate the macros entirely.
MFC r216058 and r216059:

r216058:

Use the SYSCTL_CHILDREN macro in kern_sysctl.c to help de-obfuscate the
code.

r216059:

Slightly modify the logic in sysctl_find_oid to reduce the indentation.
There should be no functional change.
MFC r216060.  This differs from the original commit in that it
preserves the KBI size of struct sysctl_oid.  Also, on stable/8 the
compiler thinks that 'len' in sysctl_sysctl_name2oid() is used
uninitialized.

Do not hold the sysctl lock across a call to the handler.  This fixes a
general LOR issue where the sysctl lock had no good place in the
hierarchy.  One specific instance is #284 on
http://sources.zabbadoz.net/freebsd/lor.html .
Fix r220012 (MFC of r216060); the KBI of sysctl_oid was *supposed* to be
preserved, but I was hasty.
MFC r219787:
  Correct broadcast frame handling. Setting bit6 of MCR0 register
  enables broadcast filtering. Make sure to clear the bit to receive
  broadcast frames. While I'm here rename the bit definition to
  reflect reality.

  Reported by:  brad@OpenBSD
MFC r218786:
  Always check memory allocation failure. If driver encounter memory
  allocation error, do not attach driver.

  Reviewed by:	marius
MFC r213841,218787-218788:
r213841:
  It seems some multi-port dc(4) controllers shares SROM of the first
  port such that reading station address from second port always
  returned 0xFF:0xFF:0xFF:0xFF:0xFF:0xFF Unfortunately it seems there
  is no easy way to know whether SROM is shared or not. Workaround
  the issue by traversing dc(4) device list and see whether we're
  using second port and use station address of controller 0 as base
  station address of second port.

  PR:		kern/79262

r218787:
  When driver have to use base softc due to lack of SROM on second
  port, copy SROM information from base softc as well and run SROM
  parser again.  This change is necessary for some dual port
  controllers to make dc(4) correctly detect PHY media based on first
  port configuration table.
  While I'm here add a check for validity of the base softc before
  duplicating SROM contents from base softc. If driver failed to
  attach to the first port it can access invalid area.

  PR:		kern/79262
  Reviewed by:	marius

r218788:
  Apply special PHY initialization code for 21143 controllers before
  any other media configuration. Otherwise some 21143 controller
  cannot establish a link. While I'm here remove the PHY
  initialization code in dc_setcfg(). Since dc_setcfg() is called
  whenever link state is changed, having the PHY initialization code
  in dc_setcfg() resulted in continuous link flips.
  After driver resets SIA, use default SIA transmit/receive
  configuration instead of disabling autosense/autonegotiation.
  Otherwise, controller fails to establish a link as well as losing
  auto-negotiation capability. For manual media configuration, always
  configure 21143 controller with specified media to ensure media
  change. This change makes ANA-6922 establish link with/without
  auto-negotiation.

  While I'm here be more strict on link UP/DOWN detection logic.

  Many thanks to marius who fixed several bugs in initial patch and
  even tested the patch on a couple of dc(4) controllers.

  PR:		kern/79262
  Reviewed by:	marius
  Tested by:	marius
MFC r218789,218820,218826-218828:
r218789:
  Remove use case of DC_TX_ONE. It was used to limit queue just 1 TX
  frame in DM910x controllers. In r67595(more than 10 years ago) it
  was replaced to use "Store and Forward" mode and made controller
  generate TX completion interrupt for every frame.

r218820:
  For controllers that have TX interrupt moderation capability,
  request TX completion interrupt for every 8-th frames. Previously
  dc(4) requested TX completion interrupt if number of queued TX
  descriptors is greater than 64. This caused a lot of TX completion
  interrupt under high TX load once driver queued more than 64 TX
  descriptors. It's quite normal to see more than 64 queued TX
  descriptors under high TX load.
  This change reduces the number of TX completion interrupts to be
  less than 17k under high TX load. Because this change does not
  generate TX completion interrupt for each frame, add reclaiming
  transmitted buffers in dc_tick not to generate false watchdog
  timeouts.
  While I'm here add check for queued descriptors in dc_txeof() since
  there is no more work to do when there is no pending descriptors.

r218826:
  Make sure to clear status word of TX descriptor in dc_list_tx_init().
  Do not update if_opackets if the transmission had failed.

r218827:
  There is no need to execute filter configuration when driver is not
  running. Remove wrong driver state change in dc_setfilt_xircom().
  While I'm here nuke unnecessary assignments.

r218828:
  Fix a long standing bug where driver handed over RX descriptor
  ownership to controller before completion of access to the
  descriptor. Driver is faking up status word so it should not give
  ownership to controller until it completes RX processing.
MFC r218830-218831:
r218830:
  Send frames only when there is a valid link and driver is running
  as well as controller has enough free TX descriptors.
  Remove check for number of queued frames before attempting to
  transmit. I guess it was added to allow draining queued frames
  even if there is no link. I'm under the impression this type of
  check should be done in upper layer. No other drivers in tree do
  that.

r218831:
  Rearrange interrupt handler a bit and remove forever loop.
  Previously dc(4) always checked whether there is pending interrupts
  and this consumed a lot of CPU cycles in interrupt handler. Limit
  the number of processing for TX/RX frames to 16. Also allow sending
  frames in the loop not to starve TX under high RX load.
  Reading DC_ISR register should be protected with driver lock,
  otherwise interrupt handler could be run(e.g. link state change)
  before the completion of dc_init_locked().

  While I'm here remove unneeded code.
MFC r218832:
  Split common TX/RX descriptor DMA tag to TX and RX DMA tags
  respectively and fix all bus_dma(9) issues seen when bounce buffers
  are used.
   o Setup frame handling had no bus_dmamap_sync(9) which prevented
     driver from configuring RX filter. Add missing bus_dmamap_sync(9)
     in both dc_setfilt_21143()/dc_setfilt_xircom() and dc_txeof().
   o Use bus_addr_t for DMA segment instead of using u_int32_t.
   o Introduce dc_dma_alloc()/dc_dma_free() functions to allocate/free
     DMA'able memory.
   o Create two DMA descriptor list for each TX/RX lists. This change
     will minimize the size of bounce buffers that would be used in
     each TX/RX path.  Previously driver had to copy both TX/RX lists
     when bounce buffer is active.
   o 21143 data sheet says descriptor list requires 4 bytes alignment.
     Remove PAGE_SIZE alignment restriction and use
     sizeof(struct dc_dec).
   o Setup frame requires 4 bytes alignment.  Remove PAGE_SIZE
     alignment restriction and use sizeof(struct dc_dec).
   o Add missing DMA map unload for both setup frame and TX/RX
     descriptor list.
   o Overhaul RX handling logic such that make driver always allocate
     new RX buffer with dc_newbuf(). Previously driver allowed to
     copy received frame with m_devget(9) after passing the
     descriptor ownership to controller. This can lead to passing
     wrong frame to upper stack.
   o Introduce dc_discard_rxbuf() which will discard received frame
     and reuse loaded DMA map and RX mbuf.
   o Correct several wrong bus_dmamap_sync(9) usage in dc_rxeof and
     dc_txeof. The TX/RX descriptor lists are updated by both driver
     and HW so READ/WRITE semantics should be used.
   o If driver failed to allocate new RX buffer, update if_iqdrops
     counter instead of if_ierrors since driver received the frame
     without errors.
   o Make sure to unload loaded setup frame DMA map in dc_txeof and
     clear the mark of setup frame of the TX descriptor in dc_txeof().
   o Add check for possible TX descriptor overruns in dc_encap() and
     move check for free buffer to caller, dc_start_locked().
   o Swap the loaded DMA map and the last DMA map for multi-segmented
     frames. Since dc_txeof() assumes the last descriptor of the
     frame has the DMA map, driver should swap the first and the last
     DMA map in dc_encap(). Previously driver tried to unload
     not-yet-loaded DMA map such that the loaded DMA map was not
     unloaded at all for multi-segmented frames.
   o Rewrite DC_RXDESC/DC_TXDESC macro to simpler one.
   o Remove definition of ETHER_ALIGN, it's already defined in
     ethernet.h.
  With this changes, dc(4) works with bounce buffers and it shall
  also fix issues which might have shown in PAE environments.

  Tested by:	marius