Commit Graph

197835 Commits

Author SHA1 Message Date
Ryan Stone
1905e4a3fd Add main() for iovctl and hook iovctl into build
Differential Revision:	https://reviews.freebsd.org/D87
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:52:41 +00:00
Ryan Stone
d9266cbaef Add functions for parsing the iovctl config file
Add two functions for parsing the iovctl config file.  The config
file is parsed using libucl[1], which accepts most YAML files and
a superset of JSON.  The first function is an ad-hoc parser that
searches the file for the PF.DEVICE configuration value.  We need
to know that value in order to fetch the schema from the kernel,
and we need the schema in order to be able to fully parse the file.

The second function parses the config file and validates it
against a schema.  This function will exit with an error message
if any validation error occurs.  If it succeeds, the configuration
is returned as an nvlist suitable for passing to the kernel.

[1] https://github.com/vstakhov/libucl

Differential Revision:	https://reviews.freebsd.org/D86
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:52:34 +00:00
Ryan Stone
dba9ec3462 Add iovctl functions for validating config
Add an function to iovctl that validates the configuration against
a schema.  This function is able to assume that the parser has
done most of the validation already and it's only responsible for
applying default VF values specified in the config file, confirming
that all required parameters have been set and that no invalid VF
numbers have been specified.

Differential Revision:	https://reviews.freebsd.org/D85
Reviewed by:		bcr
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:52:28 +00:00
Ryan Stone
b3c0355681 Add manpage documenting iovctl config file format.
Differential Revision:	https://reviews.freebsd.org/D84
Reviewed by:		emaste, bcr, wblock
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:52:21 +00:00
Ryan Stone
8129906902 Add a manpage for iovctl(8)
Differential Revision:	https://reviews.freebsd.org/D83
Reviewed by:		wblock
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:52:15 +00:00
Ryan Stone
8625a33ea1 Revert r279454. The new directory didn't get added to svn properly.
Pointy hat to: rstone
2015-03-01 00:44:15 +00:00
Ryan Stone
b431478e05 Add main() for iovctl and hook iovctl into build
Differential Revision:	https://reviews.freebsd.org/D87
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:41:17 +00:00
Ryan Stone
5cc26e6342 Pass SR-IOV configuration to kernel using an nvlist
Pass all SR-IOV configuration to the kernel using an nvlist.  The
main benefit that this offers is flexibility.  It allows a driver
to accept any number of parameters of any type supported by the
SR-IOV configuration infrastructure with having to make any
changes outside of the driver.

It also offers the user very fine-grained control over the
configuration of the VFs -- if they want, they can have different
configuration applied to every VF.

Differential Revision:	https://reviews.freebsd.org/D82
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:57 +00:00
Ryan Stone
3c22f2153c Add function to validate the consistency of SR-IOV config
Add a function that validates that the user-provided SR-IOV
configuration is valid.  This includes basic checks that the
structure of the configuration is correct (e.g. all required
configuration nodes are present) as well as validating against
a configuration schema.

The schema validation consists of:
 - Ensuring that all required config parameters are present.
 - If the schema defines a default value for a parameter,
   adding the default value if the parameter is not set.
 - Ensuring that no parameters are specified in the config
   that are not defined in the schema.
 - Ensuring that have the correct type defined in the schema.
 - Ensuring that no configuration nodes are present for devices
   that do not exist.  For example, if 2 VFs are configured,
   then we validate that a node called VF-5 does not exist.

Differential Revision:	https://reviews.freebsd.org/D81
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:51 +00:00
Ryan Stone
1191f7156f Add infrastructure for exporting config schema from PF drivers
Differential Revision:	https://reviews.freebsd.org/D80
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:42 +00:00
Ryan Stone
6c3162c4df Add interface to destroy SR-IOV VFs
Differential Revision:	https://reviews.freebsd.org/D79
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:34 +00:00
Ryan Stone
e9309eac19 Allocate PCI I/O memory spaces for VFs
When creating VFs, we must size each SR-IOV BAR on the PF and
allocate a configuous I/O memory window large enough for every VF.
However, the window only needs to be aligned to a boundary equal
to the size of the window for a single VF.

When a VF attempts to allocate an I/O memory resource, we must
intercept the request in the pci driver and pass it off to the
SR-IOV code, which will allocate the correct window from the
pre-allocated memory space for the PF.

Inform the pci driver about the size and address of the BARs on
the VF when the VF is created.  This is required by pciconf -b and
bhyve.

Differential Revision:	https://reviews.freebsd.org/D78
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:26 +00:00
Ryan Stone
5060ec97d4 Emulate the Device ID and Vendor ID registers for VFs
The SR-IOV standard requires VFs to read all-ones when the VID
and DID registers are read.  The VMM (hypervisor) is required to
emulate them instead.  Make pci_read_config() do this emulation.

Change pci_user.c to use pci_read_config() to read config space
registers instead of going directly to the pcib so that the
emulated VID/DID registers work correctly on VFs.  This is
required both for pciconf and bhyve PCI passthrough.

Differential Revision:	https://reviews.freebsd.org/D77
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:19 +00:00
Ryan Stone
9bfb1e36d9 Implement interface to create SR-IOV Virtual Functions
Implement the interace to create SR-IOV Virtual Functions (VFs).
When a driver registers that they support SR-IOV by calling
pci_setup_iov(), the SR-IOV code creates a new node in /dev/iov
for that device.  An ioctl can be invoked on that device to
create VFs and have the driver initialize them.

At this point, allocating memory I/O windows (BARs) is not
supported.

Differential Revision:	https://reviews.freebsd.org/D76
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:09 +00:00
Ryan Stone
e1de57232c Add manpages for SR-IOV enable/disable driver interface
Differential Revision:	https://reviews.freebsd.org/D75
Reviewed by:		wblock
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:40:01 +00:00
Ryan Stone
7d971e363e Document pci_iov_attach/detach in pci.9
Differential Revision:	https://reviews.freebsd.org/D74
Reviewed by:		bcr, wblock, emaste
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:39:55 +00:00
Ryan Stone
a15f820a27 Allow passthrough devices to be hinted.
Allow the ppt driver to attach to devices that were hinted to be
passthrough devices by the PCI code creating them with a driver
name of "ppt".

Add a tunable that allows the IOMMU to be forced to be used.  With
SR-IOV passthrough devices the VFs may be created after vmm.ko is
loaded.  The current code will not initialize the IOMMU in that
case, meaning that the passthrough devices can't actually be used.

Differential Revision:	https://reviews.freebsd.org/D73
Reviewed by:		neel
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:39:48 +00:00
Ryan Stone
2397d2d817 Add some pcib methods to get ARI-related information
Differential Revision:	https://reviews.freebsd.org/D72
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:39:40 +00:00
Ryan Stone
5ce88dc6da Refactor PCI resource allocation
Refactor PCI resource allocation code to allow a request for a
memory-mapped I/O window that is a multiple of a requested size.
This is needed by the SR-IOV code because the VF BARs are all
allocated contiguously.  We can't just allocate a resource that is
a multiple of a single VF BAR because the size of an allocation
implies its alignment requirement.

Differential Revision:	https://reviews.freebsd.org/D71
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:39:33 +00:00
Ryan Stone
2f5055a9b0 Refactor PCI device creation
Refactor creation of PCI devices into helper methods that can be
used by the VF creation code.

Differential Revision:	https://reviews.freebsd.org/D67
Reviewed by:		jhb
MFC after: 		1 month
Sponsored by:		Sandvine Inc.
2015-03-01 00:39:26 +00:00
Ryan Stone
081abde45c Fix build of nv_tests.cc
nv_tests.cc managed to get two copies of several functions due to me
applying a patch in an unclean working tree.  My kingdom for an
"svn clean" command.

MFC after:	1 month
X-MFC-With:	r279424
2015-03-01 00:37:23 +00:00
Ryan Stone
4d6a976e37 Move libnv into the kernel and hook it into the kernel build
Differential Revision:		https://reviews.freebsd.org/D1883
Reviewed by:			jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:34:27 +00:00
Ryan Stone
814f9a1824 Add macros to make code compile in kernel
Make it possible to compile libnv in the kernel.  Mostly this
involves wrapping functions that have a different signature in
the kernel and in userland (e.g. malloc()) in a macro that will
conditionally expand to the right API depending on whether the
code is being compiled for the kernel or not.

I have also #ifdef'ed out all of file descriptor-handling code,
as well as the unsafe varargs functions.

Differential Revision:		https://reviews.freebsd.org/D1882
Reviewed by:			jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc
2015-03-01 00:22:53 +00:00
Ryan Stone
296a8144aa Allow Illumos code to co-exist with nv(9)
Differential Revision:		https://reviews.freebsd.org/D1881
Reviewed by:			jfv, will
Suggested by:			pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc
2015-03-01 00:22:45 +00:00
Ryan Stone
19a4afb3e6 Prevent creation of an invalid nvlist
If an nvlist is set as a child of another nvlist with
nvlist_move_nvlist then fail the operation and set the parent
nvlist to the error state.

Differential Revision:		https://reviews.freebsd.org/D1880
Reviewers:			jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc
2015-03-01 00:22:38 +00:00
Ryan Stone
ed007c94ba Don't allocate memory for operations that do not insert
Almost every operation performed on an nvlist was allocating a
new string to hold the key name.  The nvlist_exists* family of
functions would always return false if they failed to allocate
the string.  The rest of the functions would outright abort().
Fix the non-varargs variants of the functions to perform the
requested operations directly and the varargs versions to
allocate the string and call into the non-varargs versions.
The varargs versions are still broken and really can't be fixed,
so we might consider axing them entirely.  However, now the non-
varargs functions are always safe to call.

Differential Revision:		https://reviews.freebsd.org/D1879
Reviewed by:			pjd, jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:22:31 +00:00
Ryan Stone
a87e516267 Add function to force an nvlist into the error state
Add an nvlist_set_error() function that can be used to force an
nvlist into the error state.  This is useful both for writing
tests and for writing APIs that use nvlists internally.

Differential Revision:		https://reviews.freebsd.org/D1878
Reviewed by:			pjd, jfv
MFC After:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:22:23 +00:00
Ryan Stone
3cd4533107 Implement asprintf in libkern
Differential Revision:		https://reviews.freebsd.org/D1877
Reviewed by:			pjd, jfv
MFC After:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:22:16 +00:00
Ryan Stone
2dfd9979d8 Extend the unit test to fix the bug caught in r277925
Differential Revision:		https://reviews.freebsd.org/D1888
MFC After:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:22:09 +00:00
Ryan Stone
7e15db629c Add tests for dnvlist_take_*
Differential Revision:		https://reviews.freebsd.org/D1876
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:22:03 +00:00
Ryan Stone
3d1b7ccbd3 Add tests for dnv_get_*
Differential Revision:		https://reviews.freebsd.org/D1875
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:21:56 +00:00
Ryan Stone
339bcfc7f8 Add tests for nvlist_free* functions
Differential Revision:		https://reviews.freebsd.org/D1874
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:21:50 +00:00
Ryan Stone
fad0a26408 Add tests for nvlist_take_*
Differential Revision:		https://reviews.freebsd.org/D1873
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:21:43 +00:00
Ryan Stone
71637d76b1 Add test cases for nvlist_move_*
Differential Revision:		https://reviews.freebsd.org/D1872
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:21:37 +00:00
Ryan Stone
6c721f8217 Add tests for nvlist_pack/unpack
Differential Revision:		https://reviews.freebsd.org/D1871
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:21:30 +00:00
Ryan Stone
6e623ffd77 Add tests for nvlist_clone
Differential Revision:		https://reviews.freebsd.org/D1870
Reviewed by:			pjd, jfv
MFC after:			1 month
Sponsored by:			Sandvine Inc
2015-03-01 00:21:24 +00:00
Ryan Stone
3075c896f0 Tests of basic nvlist add functions
Differential Revision:		https://reviews.freebsd.org/D1869
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:20:57 +00:00
Ryan Stone
c58da4beb1 Revert r279422. My "apply patch and commit" script wasn't adding
new files properly.

Pointy hat to: rstone
2015-03-01 00:05:45 +00:00
Ryan Stone
65d1148aa6 Tests of basic nvlist add functions
Differential Revision:		https://reviews.freebsd.org/D1869
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:01:44 +00:00
Ryan Stone
da8c9a4fb0 Make libnv headers includable from C++
Differential Revision:		https://reviews.freebsd.org/D1868
Reviewed by:			jfv, pjd
MFC after:			1 month
Sponsored by:			Sandvine Inc.
2015-03-01 00:01:36 +00:00
Adrian Chadd
0f3ec57676 Add another register definition for the AR8327.
Obtained from:	OpenWRT
2015-02-28 23:59:29 +00:00
Mark Johnston
1e28e010e4 Remove the old DTrace test suite makefile - it was somewhat primitive and
mostly unmaintained, and it has been superseded by the infrastructure added
in r279418.

Reviewed by:	ngie
Sponsored by:	EMC / Isilon Storage Divison
2015-02-28 23:35:29 +00:00
Mark Johnston
4ddbe5ac37 Add infrastructure to integrate the DTrace test suite with Kyua.
For each test category, we generate a script containing ATF test cases for
the tests under that category. Each test case simply runs dtest.pl (the
upstream test harness) with the corresponding test files. The exclude.sh
script is used to record info about tests which should be skipped or are
expected to fail; it is used to generate atf_skip and atf_expect_fail calls.
The genmakefiles.sh script can be used to regenerate the test makefiles when
new tests are brought it from upstream.

The test suite is currently not connected to the build as there is a small
number of lingering test issues which still need to be worked out. In the
meantime however, the test suite can be easily built and installed
manually from cddl/usr.sbin/dtrace/tests.

Reviewed by:	ngie
Sponsored by:	EMC / Isilon Storage Division
2015-02-28 23:30:06 +00:00
Mark Johnston
d914572890 Use the -shared option to create a shared library.
MFC after:	1 week
2015-02-28 23:14:35 +00:00
Mark Johnston
24d6f0ffa5 Remove a leading tab that causes a make(1) error when running the test.
MFC after:	1 week
2015-02-28 23:11:18 +00:00
Mark Johnston
8ddb6d86de Only kill sleep processes that were forked from the test script.
MFC after:	1 week
2015-02-28 23:10:26 +00:00
Mark Johnston
2c4c1a261e Stop hard-coding an incorrect path to rm(1).
MFC after:	1 week
2015-02-28 23:09:01 +00:00
Ryan Stone
ce6682d990 Add a missing include of an options header.
watchdog.c does an #ifdef DDB but does not #include "opt_ddb.h".
Fixing this turned up a missing include file.

MFC after:	1 week
X-MFC-With:	r261495, r279410
2015-02-28 22:37:48 +00:00
Alexander Kabaev
0fd841369a Do not leak 'copy' buffer if bmap_truncate_indirect fails.
Reported by: Brainy Code Scanner, by Maxime Villard.
MFC after: 2 weeks
2015-02-28 22:24:45 +00:00
Enji Cooper
c14bdeb07e Unbreak 'make depend' with sfxge by removing debugging code activated in the
INET || INET6 case

X-MFC with: r279398
Pointyhat to: arybchik
2015-02-28 21:50:04 +00:00