xref: /freebsd/share/man/man9/pci_iov_schema.9 (revision fe3ff217dd5c53ef0b0a5cd7a1142095ba4ecf63)
11fe9f6f6SRyan Stone.\"
21fe9f6f6SRyan Stone.\" Copyright (c) 2014 Sandvine Inc.
31fe9f6f6SRyan Stone.\" All rights reserved.
41fe9f6f6SRyan Stone.\"
51fe9f6f6SRyan Stone.\" Redistribution and use in source and binary forms, with or without
61fe9f6f6SRyan Stone.\" modification, are permitted provided that the following conditions
71fe9f6f6SRyan Stone.\" are met:
81fe9f6f6SRyan Stone.\" 1. Redistributions of source code must retain the above copyright
91fe9f6f6SRyan Stone.\"    notice, this list of conditions and the following disclaimer.
101fe9f6f6SRyan Stone.\" 2. Redistributions in binary form must reproduce the above copyright
111fe9f6f6SRyan Stone.\"    notice, this list of conditions and the following disclaimer in the
121fe9f6f6SRyan Stone.\"    documentation and/or other materials provided with the distribution.
131fe9f6f6SRyan Stone.\"
141fe9f6f6SRyan Stone.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151fe9f6f6SRyan Stone.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161fe9f6f6SRyan Stone.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171fe9f6f6SRyan Stone.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181fe9f6f6SRyan Stone.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191fe9f6f6SRyan Stone.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201fe9f6f6SRyan Stone.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211fe9f6f6SRyan Stone.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221fe9f6f6SRyan Stone.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231fe9f6f6SRyan Stone.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241fe9f6f6SRyan Stone.\" SUCH DAMAGE.
251fe9f6f6SRyan Stone.\"
261fe9f6f6SRyan Stone.\" $FreeBSD$
271fe9f6f6SRyan Stone.\"
28*fe3ff217SPatrick Kelsey.Dd July 8, 2015
2961d010faSChristian Brueffer.Dt PCI_IOV_SCHEMA 9
301fe9f6f6SRyan Stone.Os
311fe9f6f6SRyan Stone.Sh NAME
321fe9f6f6SRyan Stone.Nm pci_iov_schema ,
331fe9f6f6SRyan Stone.Nm pci_iov_schema_alloc_node ,
341fe9f6f6SRyan Stone.Nm pci_iov_schema_add_bool ,
351fe9f6f6SRyan Stone.Nm pci_iov_schema_add_string ,
361fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint8 ,
371fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint16 ,
381fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint32 ,
391fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint64 ,
401fe9f6f6SRyan Stone.Nm pci_iov_schema_add_unicast_mac
411fe9f6f6SRyan Stone.Nd PCI SR-IOV config schema interface
421fe9f6f6SRyan Stone.Sh SYNOPSIS
431fe9f6f6SRyan Stone.In machine/stdarg.h
441fe9f6f6SRyan Stone.In sys/nv.h
451fe9f6f6SRyan Stone.In sys/iov_schema.h
461fe9f6f6SRyan Stone.Ft nvlist_t *
471fe9f6f6SRyan Stone.Fn pci_iov_schema_alloc_node "void"
481fe9f6f6SRyan Stone.Ft void
491fe9f6f6SRyan Stone.Fn pci_iov_schema_add_bool "nvlist_t *schema" "const char *name" \
501fe9f6f6SRyan Stone"uint32_t flags" "int defaultVal"
511fe9f6f6SRyan Stone.Ft void
521fe9f6f6SRyan Stone.Fn pci_iov_schema_add_string "nvlist_t *schema" "const char *name" \
531fe9f6f6SRyan Stone"uint32_t flags" "const char *defaultVal"
541fe9f6f6SRyan Stone.Ft void
551fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint8 "nvlist_t *schema" "const char *name" \
561fe9f6f6SRyan Stone"uint32_t flags" "uint8_t defaultVal"
571fe9f6f6SRyan Stone.Ft void
581fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint16 "nvlist_t *schema" "const char *name" \
591fe9f6f6SRyan Stone"uint32_t flags" "uint16_t defaultVal"
601fe9f6f6SRyan Stone.Ft void
611fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint32 "nvlist_t *schema" "const char *name" \
621fe9f6f6SRyan Stone"uint32_t flags" "uint32_t defaultVal"
631fe9f6f6SRyan Stone.Ft void
641fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint64 "nvlist_t *schema" "const char *name" \
651fe9f6f6SRyan Stone"uint32_t flags" "uint64_t defaultVal"
661fe9f6f6SRyan Stone.Ft void
671fe9f6f6SRyan Stone.Fn pci_iov_schema_add_unicast_mac "nvlist_t *schema" "const char *name" \
681fe9f6f6SRyan Stone"uint32_t flags" "const uint8_t *defaultVal"
691fe9f6f6SRyan Stone.Sh DESCRIPTION
701fe9f6f6SRyan StoneThe PCI Single-Root I/O Virtualization
711fe9f6f6SRyan Stone.Pq SR-IOV
721fe9f6f6SRyan Stoneconfiguration schema is a data
731fe9f6f6SRyan Stonestructure that describes the device-specific configuration parameters that a PF
741fe9f6f6SRyan Stonedriver will accept when SR-IOV is enabled on the PF device.
751fe9f6f6SRyan StoneEach PF driver defines two schema instances: the PF schema and the VF schema.
761fe9f6f6SRyan StoneThe PF schema describes configuration that applies to the PF device as a whole.
771fe9f6f6SRyan StoneThe VF schema describes configuration that applies to an individual VF device.
781fe9f6f6SRyan StoneDifferent VF devices may have different configuration applied to them, as long
791fe9f6f6SRyan Stoneas the configuration for each VF conforms to the VF schema.
801fe9f6f6SRyan Stone.Pp
811fe9f6f6SRyan StoneA PF driver builds a configuration schema by first allocating a schema node and
821fe9f6f6SRyan Stonethen adding configuration parameter specifications to the schema.
831fe9f6f6SRyan StoneThe configuration parameter specification consists of a name and a value type.
841fe9f6f6SRyan Stone.Pp
851fe9f6f6SRyan StoneConfiguration parameter names are case-insensitive.
861fe9f6f6SRyan StoneIt is an error to specify two or more configuration parameters with the same
871fe9f6f6SRyan Stonename.
881fe9f6f6SRyan StoneIt is also an error to specific a configuration parameter that uses the same
891fe9f6f6SRyan Stonename as a configuration parameter used by the SR-IOV infrastructure.
901fe9f6f6SRyan StoneSee
911fe9f6f6SRyan Stone.Xr iovctl.conf 5
921fe9f6f6SRyan Stonefor documentation of all configuration parameters used by the SR-IOV
931fe9f6f6SRyan Stoneinfrastructure.
941fe9f6f6SRyan Stone.Pp
951fe9f6f6SRyan StoneThe parameter type constrains the possible values that the configuration
961fe9f6f6SRyan Stoneparameter may take.
971fe9f6f6SRyan Stone.Pp
981fe9f6f6SRyan StoneA configuration parameter may be specified as a required parameter by setting
991fe9f6f6SRyan Stonethe
1001fe9f6f6SRyan Stone.Dv IOV_SCHEMA_REQUIRED
1011fe9f6f6SRyan Stoneflag in the
1021fe9f6f6SRyan Stone.Pa flags
1031fe9f6f6SRyan Stoneargument.
1041fe9f6f6SRyan StoneRequired parameters must be specified by the user when SR-IOV is enabled.
1051fe9f6f6SRyan StoneIf the user does not specify a required parameter, the SR-IOV infrastructure
1061fe9f6f6SRyan Stonewill abort the request to enable SR-IOV and return an error to the user.
1071fe9f6f6SRyan Stone.Pp
1081fe9f6f6SRyan StoneAlternatively, a configuration parameter may be given a default value by
1091fe9f6f6SRyan Stonesetting the
1101fe9f6f6SRyan Stone.Dv IOV_SCHEMA_HASDEFAULT
1111fe9f6f6SRyan Stoneflag in the
1121fe9f6f6SRyan Stone.Pa flags
1131fe9f6f6SRyan Stoneargument.
1141fe9f6f6SRyan StoneIf a configuration parameter has a default value but the user has not specified
1151fe9f6f6SRyan Stonea value for that parameter, then the SR-IOV infrastructure will apply
1161fe9f6f6SRyan Stone.Pa defaultVal
1171fe9f6f6SRyan Stonefor that parameter in the configuration before passing it to the PF driver.
1181fe9f6f6SRyan StoneIt is an error for the value of the
1191fe9f6f6SRyan Stone.Pa defaultVal
1201fe9f6f6SRyan Stoneparameter to not conform to the restrictions of the specified type.
1211fe9f6f6SRyan StoneIf this flag is not specified then the
1221fe9f6f6SRyan Stone.Pa defaultVal
1231fe9f6f6SRyan Stoneargument is ignored.
1241fe9f6f6SRyan StoneThis flag is not compatible with the
1251fe9f6f6SRyan Stone.Dv IOV_SCHEMA_REQUIRED
1261fe9f6f6SRyan Stoneflag; it is an error to specify both on the same parameter.
1271fe9f6f6SRyan Stone.Pp
1281fe9f6f6SRyan StoneThe SR-IOV infrastructure guarantees that all configuration parameters that are
1291fe9f6f6SRyan Stoneeither specified as required or given a default value will be present in the
1301fe9f6f6SRyan Stoneconfiguration passed to the PF driver.
1311fe9f6f6SRyan StoneConfiguration parameters that are neither specified as required nor given a
1321fe9f6f6SRyan Stonedefault value are optional and may or may not be present in the configuration
1331fe9f6f6SRyan Stonepassed to the PF driver.
1341fe9f6f6SRyan Stone.Pp
1351fe9f6f6SRyan StoneIt is highly recommended that a PF driver reserve the use of optional parameters
1361fe9f6f6SRyan Stonefor configuration that is truly optional.
1371fe9f6f6SRyan StoneFor example, a Network Interface PF device might have the option to encapsulate
1381fe9f6f6SRyan Stoneall traffic to and from a VF device in a vlan tag.
1391fe9f6f6SRyan StoneThe PF driver could expose that option as a "vlan" parameter accepting an
1401fe9f6f6SRyan Stoneinteger argument specifying the vlan tag.
1411fe9f6f6SRyan StoneIn this case, it would be appropriate to set the "vlan" parameter as an optional
1421fe9f6f6SRyan Stoneparameter as it would be legitimate for a VF to be configured to have no vlan
1431fe9f6f6SRyan Stonetagging enabled at all.
1441fe9f6f6SRyan Stone.Pp
1451fe9f6f6SRyan StoneAlternatively, if the PF device had an boolean option that controlled whether
1461fe9f6f6SRyan Stonethe VF was allowed to change its MAC address, it would not be appropriate to
1471fe9f6f6SRyan Stoneset this parameter as optional.
1481fe9f6f6SRyan StoneThe PF driver must either allow the MAC to change or not, so it would be more
1491fe9f6f6SRyan Stoneappropriate for the PF driver to document the default behaviour by specifying
1501fe9f6f6SRyan Stonea default value in the schema
1511fe9f6f6SRyan Stone.Po or potentially force the user to make the choice by setting the parameter
1521fe9f6f6SRyan Stoneto be required
1531fe9f6f6SRyan Stone.Pc .
1541fe9f6f6SRyan Stone.Pp
1551fe9f6f6SRyan StoneConfiguration parameters that have security implications must default to the
1561fe9f6f6SRyan Stonemost secure configuration possible.
1571fe9f6f6SRyan Stone.Pp
1581fe9f6f6SRyan StoneAll device-specific configuration parameters must be documented in the manual
1591fe9f6f6SRyan Stonepage for the PF driver, or in a separate manual page that is cross-referenced
1601fe9f6f6SRyan Stonefrom the main driver manual page.
1611fe9f6f6SRyan Stone.Pp
1621fe9f6f6SRyan StoneIt is not necessary for a PF driver to check for failure from any of these
1631fe9f6f6SRyan Stonefunctions.
1641fe9f6f6SRyan StoneIf an error occurs, it is flagged in the schema.
1651fe9f6f6SRyan StoneThe
1661fe9f6f6SRyan Stone.Xr pci_iov_attach 9
1671fe9f6f6SRyan Stonefunction checks for this error and will fail to initialize SR-IOV on the PF
1681fe9f6f6SRyan Stonedevice if an error is set in the schema.
1691fe9f6f6SRyan StoneIf this occurs, it is recommended that the PF driver still succeed in attaching
1701fe9f6f6SRyan Stoneand run with SR-IOV disabled on the device.
1711fe9f6f6SRyan Stone.Pp
1721fe9f6f6SRyan StoneThe
1731fe9f6f6SRyan Stone.Fn pci_iov_schema_alloc_node
1741fe9f6f6SRyan Stonefunction is used to allocate an empty configuration schema.
1751fe9f6f6SRyan StoneIt is not necessary to check for failure from this function.
1761fe9f6f6SRyan StoneThe SR-IOV infrastructure will gracefully handle failure to allocate a schema
1771fe9f6f6SRyan Stoneand will simply not enable SR-IOV on the PF device.
1781fe9f6f6SRyan Stone.Pp
1791fe9f6f6SRyan StoneThe
1801fe9f6f6SRyan Stone.Fn pci_iov_schema_add_bool
1811fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
1821fe9f6f6SRyan Stonethe name
1831fe9f6f6SRyan Stone.Pa name
1841fe9f6f6SRyan Stoneand having a boolean type.
1851fe9f6f6SRyan StoneBoolean values can only take the value true or false (1 or 0, respectively).
1861fe9f6f6SRyan Stone.Pp
1871fe9f6f6SRyan StoneThe
1881fe9f6f6SRyan Stone.Fn pci_iov_schema_add_string
1891fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
1901fe9f6f6SRyan Stonethe name
1911fe9f6f6SRyan Stone.Pa name
1921fe9f6f6SRyan Stoneand having a string type.
1931fe9f6f6SRyan StoneString values are standard C strings.
1941fe9f6f6SRyan Stone.Pp
1951fe9f6f6SRyan StoneThe
1961fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint8
1971fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
1981fe9f6f6SRyan Stonethe name
1991fe9f6f6SRyan Stone.Pa name
2001fe9f6f6SRyan Stoneand having a
2011fe9f6f6SRyan Stone.Vt uint8_t
2021fe9f6f6SRyan Stonetype.
2031fe9f6f6SRyan StoneValues of type
2041fe9f6f6SRyan Stone.Vt uint8_t
2051fe9f6f6SRyan Stoneare unsigned integers in the range 0 to 255, inclusive.
2061fe9f6f6SRyan Stone.Pp
2071fe9f6f6SRyan StoneThe
2081fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint16
2091fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
2101fe9f6f6SRyan Stonethe name
2111fe9f6f6SRyan Stone.Pa name
2121fe9f6f6SRyan Stoneand having a
2131fe9f6f6SRyan Stone.Vt uint16_t
2141fe9f6f6SRyan Stonetype.
2151fe9f6f6SRyan StoneValues of type
2161fe9f6f6SRyan Stone.Vt uint16_t
2171fe9f6f6SRyan Stoneare unsigned integers in the range 0 to 65535, inclusive.
2181fe9f6f6SRyan Stone.Pp
2191fe9f6f6SRyan StoneThe
2201fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint32
2211fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
2221fe9f6f6SRyan Stonethe name
2231fe9f6f6SRyan Stone.Pa name
2241fe9f6f6SRyan Stoneand having a
2251fe9f6f6SRyan Stone.Vt uint32_t
2261fe9f6f6SRyan Stonetype.
2271fe9f6f6SRyan StoneValues of type
2281fe9f6f6SRyan Stone.Vt uint32_t
2291fe9f6f6SRyan Stoneare unsigned integers in the range 0 to
230*fe3ff217SPatrick Kelsey.Pq 2**32 - 1 ,
2311fe9f6f6SRyan Stoneinclusive.
2321fe9f6f6SRyan Stone.Pp
2331fe9f6f6SRyan StoneThe
2341fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint64
2351fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
2361fe9f6f6SRyan Stonethe name
2371fe9f6f6SRyan Stone.Pa name
2381fe9f6f6SRyan Stoneand having a
2391fe9f6f6SRyan Stone.Vt uint64_t
2401fe9f6f6SRyan Stonetype.
2411fe9f6f6SRyan StoneValues of type
2421fe9f6f6SRyan Stone.Vt uint64_t
2431fe9f6f6SRyan Stoneare unsigned integers in the range 0 to
244*fe3ff217SPatrick Kelsey.Pq 2**64 - 1 ,
2451fe9f6f6SRyan Stoneinclusive.
2461fe9f6f6SRyan Stone.Pp
2471fe9f6f6SRyan StoneThe
2481fe9f6f6SRyan Stone.Fn pci_iov_schema_add_unicast_mac
2491fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with
2501fe9f6f6SRyan Stonethe name
2511fe9f6f6SRyan Stone.Pa name
2521fe9f6f6SRyan Stoneand having a unicast-mac type.
2531fe9f6f6SRyan StoneValues of type unicast-mac are binary values exactly 6 bytes long.
2541fe9f6f6SRyan StoneThe MAC address is guaranteed to not be a multicast or broadcast address.
2551fe9f6f6SRyan Stone.Sh RETURN VALUES
2561fe9f6f6SRyan StoneThe
2571fe9f6f6SRyan Stone.Fn pci_iov_schema_alloc_node
2581fe9f6f6SRyan Stonefunction returns a pointer to the allocated schema, or NULL if a failure occurs.
2591fe9f6f6SRyan Stone.Sh SEE ALSO
2601fe9f6f6SRyan Stone.Xr pci 9 ,
261f3bb9251SJohn Baldwin.Xr PCI_IOV_ADD_VF 9 ,
262f3bb9251SJohn Baldwin.Xr PCI_IOV_INIT 9
2631fe9f6f6SRyan Stone.Sh AUTHORS
2641fe9f6f6SRyan StoneThis manual page was written by
2651fe9f6f6SRyan Stone.An Ryan Stone Aq rstone@FreeBSD.org .
266