- Remove two write-only local variables
  - Remove unused element in the vtnet_rxq structure

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267520 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Remove kernel specific macro out of the VirtIO PCI header file

The eventual goal is to share this file with userland, so
remove the macro that is only specific for virtio_pci(4).
Instead, add the VIRTIO_PCI_CONFIG_OFF macro from Linux to
get the config size whether MSIX is enabled or not.

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267521 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Move the VIRTIO_RING_F_* defines out of virtqueue.h into virtio_config.h

These defines are applicable to userland too, but virtqueue.h contains
the kernel virtqueue interface, and is therefore not usable in userland.

Note that Linux places these defines in virtio_ring.h, but I don't want
the drivers including this header file to keep the VirtIO ring opaque to
everything but the virtqueue.

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267522 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Make the feature negotiation code easier to follow

MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267523 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Force two byte alignment for all control message headers

The header structure consists of two 1-byte elements, but it must always
be describable by a single SG entry. Note for consistency, specify the
alignment everywhere, even if the structure has the appropriate natural
alignment since it contains a uint16_t.

Obtained from:	DragonFlyBSD
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267524 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: fix style in pv.c

Fix the lenght of some comments, and also add proper indentation to
xen_init_ops

Sponsored by: Citrix Systems R&D
Approved by: gibbs


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267525 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
amd64/i386: introduce APIC hooks for different APIC implementations.

This is needed for Xen PV(H) guests, since there's no hardware lapic
available on this kind of domains. This commit should not change
functionality.

Sponsored by: Citrix Systems R&D
Reviewed by: jhb
Approved by: gibbs

amd64/include/cpu.h:
amd64/amd64/mp_machdep.c:
i386/include/cpu.h:
i386/i386/mp_machdep.c:
 - Remove lapic_ipi_vectored hook from cpu_ops, since it's now
   implemented in the lapic hooks.

amd64/amd64/mp_machdep.c:
i386/i386/mp_machdep.c:
 - Use lapic_ipi_vectored directly, since it's now an inline function
   that will call the appropiate hook.

x86/x86/local_apic.c:
 - Prefix bare metal public lapic functions with native_ and mark them
   as static.
 - Define default implementation of apic_ops.

x86/include/apicvar.h:
 - Declare the apic_ops structure and create inline functions to
   access the hooks, so the change is transparent to existing users of
   the lapic_ functions.

x86/xen/hvm.c:
 - Switch to use the new apic_ops.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267526 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: add hooks for Xen PV APIC

Create the necessary hooks in order to provide a Xen PV APIC
implementation that can be used on PVH. Most of the lapic ops
shouldn't be called on Xen, since we trap those operations at a higher
layer.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

x86/xen/hvm.c:
x86/xen/xen_apic.c:
 - Move IPI related code to xen_apic.c

x86/xen/xen_apic.c:
 - Introduce Xen PV APIC implementation, most of the functions of the
   lapic interface should never be called when running as PV(H) guest,
   so make sure FreeBSD panics when trying to use one of those.
 - Define the Xen APIC implementation in xen_apic_ops.

xen/xen_pv.h:
 - Extern declaration of the xen_apic struct.

x86/xen/pv.c:
 - Use xen_apic_ops as apic_ops when running as PVH guest.

conf/files.amd64:
conf/files.i386:
 - Include the xen_apic.c file in the build of i386/amd64 kernels
   using XENHVM.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267527 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: introduce xenpv bus

Create a dummy bus so top level Xen devices can attach to it (instead
of attaching directly to the nexus). This allows to have all the Xen
related devices grouped under a single bus.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

x86/xen/xenpv.c:
 - Attach the xenpv bus when running as a Xen guest.
 - Attach the ISA bus if needed, in order to attach syscons.

conf/files.amd6:
conf/files.i386:
 - Include the xenpv.c file in the build of i386/amd64 kernels using
   XENHVM.

dev/xen/console/console.c:
dev/xen/timer/timer.c:
xen/xenstore/xenstore.c:
 - Attach to the xenpv bus instead of the Nexus.

dev/xen/xenpci/xenpci.c:
 - Xen specific devices on PVHVM guests are no longer attached to the
   xenpci device, they are instead attached to the xenpv bus, remove
   the now unused methods.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267528 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: create a PV CPU device for PVH guests

Since there's no ACPI on PVH guests, we need to create a dummy CPU
device in order to fill the pcpu->pc_device field.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

dev/xen/pvcpu/pvcpu.c:
 - Create a dummy CPU device for PVH guests in order to fill the
   per-cpu pc_device field.

conf/files:
 - Add the pvcpu device to kernels using XEN or XENHVM options.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267529 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: create a Xen nexus to use in PV/PVH

Introduce a Xen specific nexus that is going to be used by Xen PV/PVH
guests.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

x86/xen/xen_nexus.c:
 - Introduce a Nexus to use on Xen PV(H) guests, this prevents PV(H)
   guests from using the legacy Nexus.

conf/files.amd64:
conf/files.i386:
 - Add the xen nexus to the build.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267530 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: add shutdown hook for PVH

Add the PV shutdown hook to PVH.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

dev/xen/control/control.c:
 - Make xen_pv_shutdown_final available on XENHVM builds.
 - Register the Xen PV shutdown hook for PVH guests.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267531 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: xenstore changes to support PVH

For PVH guests the xenstore parameters are fetched from the start_info
struct, just like on PV.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

xen/xenstore/xenstore.c:
 - Fetch xenstore event channel port from start_info.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267532 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: init gnttab from xenpv

Currently the grant table is initialized from xenstore, but a better
place to do this would be xenpv, so move grant table initialization
there.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

x86/xen/xenpv.c:
 - Add gnttab initialization.

xen/xenstore/xenstore.c:
 - Remove gnttab initialization.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267533 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: unify gnttab initialization for PVHVM and PVH

Switch the initialization of gnttab to use an unused physical memory
range for both PVHVM and PVH.

In the past PVHVM was using the xenpci BAR, but there's no reason to
do that, and in fact FreeBSD was probably doing it because it was the
way it was done in Windows, were drivers cannot probably request for
unused physical memory ranges, but it was never enforced in the
hypervisor.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

xen/gnttab.c:
 - Allocate contiguous physical memory for grant table frames for both
   PVHVM and PVH.
 - Since gnttab is not a device, use the xenpv device in order to
   request for this allocation.

dev/xen/xenpci/xenpcivar.h:
dev/xen/xenpci/xenpci.c:
 - Remove the now unused xenpci_alloc_space and xenpci_alloc_space_int
   functions.

xen/gnttab.h:
 - Change the prototype of gnttab_init and gnttab_resume, that now
   takes a device_t parameter.

dev/xen/control/control.c:
x86/xen/xenpv.c:
 - Changes to accomodate the new prototype of gnttab_init and
   gnttab_resume.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267534 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
isa: allow ISA bus to attach to xenpv bus

This is needed because syscons depends on ISA.

Sponsored by: Citrix Systems R&D
Approved by: gibbs

x86/isa/isa.c:
 - Allow the ISA bus to attach to xenpv.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267535 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
xen: add missing files

Commit missing files that actually belong to previous commits.

Sponsored by: Citrix Systems R&D
Approved by: gibbs


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267536 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add support for VERIFY(10/12/16) and COMPARE AND WRITE SCSI commands.

Make data_submit backends method support not only read and write requests,
but also two new ones: verify and compare.  Verify just checks readability
of the data in specified location without transferring them outside.
Compare reads the specified data and compares them to received data,
returning error if they are different.

VERIFY(10/12/16) commands request either verify or compare from backend,
depending on BYTCHK CDB field.  COMPARE AND WRITE command executed in two
stages: first it requests compare, and then, if succeesed, requests write.
Atomicity of operation is guarantied by CTL request ordering code.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267537 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix destruction of character devices by passing correct pointer to
kernel in IOCTL request.

Submitted by:	Andrey Zholos <aaz@q-fu.com>


git-svn-id: svn+ssh://svn.freebsd.org/base/head@267543 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Update license to strptime(3) implementation.

Our strptime(3) implementation was the base for the illumos
implementation and after contacting the author, Kevin Rudy
stated the code is under a 2-Clause BSD License [1]

After reviewing our local changes to the file in question,
the FreeBSD Foundation has agreed that their contributions
to this file are not required to carry clause 3 or 4 so
the file can be relicensed as in Illumos [2].

References:

[1] https://www.illumos.org/issues/357
[2] Illumos Revision:		13222:02526851ba75

Approved:	core (jhb)
Approved:	FreeBSD Foundation (emaste)
MFC after:	4 days


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