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.\" 26*fe3ff217SPatrick Kelsey.Dd July 8, 2015 2761d010faSChristian Brueffer.Dt PCI_IOV_SCHEMA 9 281fe9f6f6SRyan Stone.Os 291fe9f6f6SRyan Stone.Sh NAME 301fe9f6f6SRyan Stone.Nm pci_iov_schema , 311fe9f6f6SRyan Stone.Nm pci_iov_schema_alloc_node , 321fe9f6f6SRyan Stone.Nm pci_iov_schema_add_bool , 331fe9f6f6SRyan Stone.Nm pci_iov_schema_add_string , 341fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint8 , 351fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint16 , 361fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint32 , 371fe9f6f6SRyan Stone.Nm pci_iov_schema_add_uint64 , 381fe9f6f6SRyan Stone.Nm pci_iov_schema_add_unicast_mac 391fe9f6f6SRyan Stone.Nd PCI SR-IOV config schema interface 401fe9f6f6SRyan Stone.Sh SYNOPSIS 411fe9f6f6SRyan Stone.In machine/stdarg.h 421fe9f6f6SRyan Stone.In sys/nv.h 431fe9f6f6SRyan Stone.In sys/iov_schema.h 441fe9f6f6SRyan Stone.Ft nvlist_t * 451fe9f6f6SRyan Stone.Fn pci_iov_schema_alloc_node "void" 461fe9f6f6SRyan Stone.Ft void 471fe9f6f6SRyan Stone.Fn pci_iov_schema_add_bool "nvlist_t *schema" "const char *name" \ 481fe9f6f6SRyan Stone"uint32_t flags" "int defaultVal" 491fe9f6f6SRyan Stone.Ft void 501fe9f6f6SRyan Stone.Fn pci_iov_schema_add_string "nvlist_t *schema" "const char *name" \ 511fe9f6f6SRyan Stone"uint32_t flags" "const char *defaultVal" 521fe9f6f6SRyan Stone.Ft void 531fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint8 "nvlist_t *schema" "const char *name" \ 541fe9f6f6SRyan Stone"uint32_t flags" "uint8_t defaultVal" 551fe9f6f6SRyan Stone.Ft void 561fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint16 "nvlist_t *schema" "const char *name" \ 571fe9f6f6SRyan Stone"uint32_t flags" "uint16_t defaultVal" 581fe9f6f6SRyan Stone.Ft void 591fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint32 "nvlist_t *schema" "const char *name" \ 601fe9f6f6SRyan Stone"uint32_t flags" "uint32_t defaultVal" 611fe9f6f6SRyan Stone.Ft void 621fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint64 "nvlist_t *schema" "const char *name" \ 631fe9f6f6SRyan Stone"uint32_t flags" "uint64_t defaultVal" 641fe9f6f6SRyan Stone.Ft void 651fe9f6f6SRyan Stone.Fn pci_iov_schema_add_unicast_mac "nvlist_t *schema" "const char *name" \ 661fe9f6f6SRyan Stone"uint32_t flags" "const uint8_t *defaultVal" 671fe9f6f6SRyan Stone.Sh DESCRIPTION 681fe9f6f6SRyan StoneThe PCI Single-Root I/O Virtualization 691fe9f6f6SRyan Stone.Pq SR-IOV 701fe9f6f6SRyan Stoneconfiguration schema is a data 711fe9f6f6SRyan Stonestructure that describes the device-specific configuration parameters that a PF 721fe9f6f6SRyan Stonedriver will accept when SR-IOV is enabled on the PF device. 731fe9f6f6SRyan StoneEach PF driver defines two schema instances: the PF schema and the VF schema. 741fe9f6f6SRyan StoneThe PF schema describes configuration that applies to the PF device as a whole. 751fe9f6f6SRyan StoneThe VF schema describes configuration that applies to an individual VF device. 761fe9f6f6SRyan StoneDifferent VF devices may have different configuration applied to them, as long 771fe9f6f6SRyan Stoneas the configuration for each VF conforms to the VF schema. 781fe9f6f6SRyan Stone.Pp 791fe9f6f6SRyan StoneA PF driver builds a configuration schema by first allocating a schema node and 801fe9f6f6SRyan Stonethen adding configuration parameter specifications to the schema. 811fe9f6f6SRyan StoneThe configuration parameter specification consists of a name and a value type. 821fe9f6f6SRyan Stone.Pp 831fe9f6f6SRyan StoneConfiguration parameter names are case-insensitive. 841fe9f6f6SRyan StoneIt is an error to specify two or more configuration parameters with the same 851fe9f6f6SRyan Stonename. 861fe9f6f6SRyan StoneIt is also an error to specific a configuration parameter that uses the same 871fe9f6f6SRyan Stonename as a configuration parameter used by the SR-IOV infrastructure. 881fe9f6f6SRyan StoneSee 891fe9f6f6SRyan Stone.Xr iovctl.conf 5 901fe9f6f6SRyan Stonefor documentation of all configuration parameters used by the SR-IOV 911fe9f6f6SRyan Stoneinfrastructure. 921fe9f6f6SRyan Stone.Pp 931fe9f6f6SRyan StoneThe parameter type constrains the possible values that the configuration 941fe9f6f6SRyan Stoneparameter may take. 951fe9f6f6SRyan Stone.Pp 961fe9f6f6SRyan StoneA configuration parameter may be specified as a required parameter by setting 971fe9f6f6SRyan Stonethe 981fe9f6f6SRyan Stone.Dv IOV_SCHEMA_REQUIRED 991fe9f6f6SRyan Stoneflag in the 1001fe9f6f6SRyan Stone.Pa flags 1011fe9f6f6SRyan Stoneargument. 1021fe9f6f6SRyan StoneRequired parameters must be specified by the user when SR-IOV is enabled. 1031fe9f6f6SRyan StoneIf the user does not specify a required parameter, the SR-IOV infrastructure 1041fe9f6f6SRyan Stonewill abort the request to enable SR-IOV and return an error to the user. 1051fe9f6f6SRyan Stone.Pp 1061fe9f6f6SRyan StoneAlternatively, a configuration parameter may be given a default value by 1071fe9f6f6SRyan Stonesetting the 1081fe9f6f6SRyan Stone.Dv IOV_SCHEMA_HASDEFAULT 1091fe9f6f6SRyan Stoneflag in the 1101fe9f6f6SRyan Stone.Pa flags 1111fe9f6f6SRyan Stoneargument. 1121fe9f6f6SRyan StoneIf a configuration parameter has a default value but the user has not specified 1131fe9f6f6SRyan Stonea value for that parameter, then the SR-IOV infrastructure will apply 1141fe9f6f6SRyan Stone.Pa defaultVal 1151fe9f6f6SRyan Stonefor that parameter in the configuration before passing it to the PF driver. 1161fe9f6f6SRyan StoneIt is an error for the value of the 1171fe9f6f6SRyan Stone.Pa defaultVal 1181fe9f6f6SRyan Stoneparameter to not conform to the restrictions of the specified type. 1191fe9f6f6SRyan StoneIf this flag is not specified then the 1201fe9f6f6SRyan Stone.Pa defaultVal 1211fe9f6f6SRyan Stoneargument is ignored. 1221fe9f6f6SRyan StoneThis flag is not compatible with the 1231fe9f6f6SRyan Stone.Dv IOV_SCHEMA_REQUIRED 1241fe9f6f6SRyan Stoneflag; it is an error to specify both on the same parameter. 1251fe9f6f6SRyan Stone.Pp 1261fe9f6f6SRyan StoneThe SR-IOV infrastructure guarantees that all configuration parameters that are 1271fe9f6f6SRyan Stoneeither specified as required or given a default value will be present in the 1281fe9f6f6SRyan Stoneconfiguration passed to the PF driver. 1291fe9f6f6SRyan StoneConfiguration parameters that are neither specified as required nor given a 1301fe9f6f6SRyan Stonedefault value are optional and may or may not be present in the configuration 1311fe9f6f6SRyan Stonepassed to the PF driver. 1321fe9f6f6SRyan Stone.Pp 1331fe9f6f6SRyan StoneIt is highly recommended that a PF driver reserve the use of optional parameters 1341fe9f6f6SRyan Stonefor configuration that is truly optional. 1351fe9f6f6SRyan StoneFor example, a Network Interface PF device might have the option to encapsulate 1361fe9f6f6SRyan Stoneall traffic to and from a VF device in a vlan tag. 1371fe9f6f6SRyan StoneThe PF driver could expose that option as a "vlan" parameter accepting an 1381fe9f6f6SRyan Stoneinteger argument specifying the vlan tag. 1391fe9f6f6SRyan StoneIn this case, it would be appropriate to set the "vlan" parameter as an optional 1401fe9f6f6SRyan Stoneparameter as it would be legitimate for a VF to be configured to have no vlan 1411fe9f6f6SRyan Stonetagging enabled at all. 1421fe9f6f6SRyan Stone.Pp 1431fe9f6f6SRyan StoneAlternatively, if the PF device had an boolean option that controlled whether 1441fe9f6f6SRyan Stonethe VF was allowed to change its MAC address, it would not be appropriate to 1451fe9f6f6SRyan Stoneset this parameter as optional. 1461fe9f6f6SRyan StoneThe PF driver must either allow the MAC to change or not, so it would be more 1471fe9f6f6SRyan Stoneappropriate for the PF driver to document the default behaviour by specifying 1481fe9f6f6SRyan Stonea default value in the schema 1491fe9f6f6SRyan Stone.Po or potentially force the user to make the choice by setting the parameter 1501fe9f6f6SRyan Stoneto be required 1511fe9f6f6SRyan Stone.Pc . 1521fe9f6f6SRyan Stone.Pp 1531fe9f6f6SRyan StoneConfiguration parameters that have security implications must default to the 1541fe9f6f6SRyan Stonemost secure configuration possible. 1551fe9f6f6SRyan Stone.Pp 1561fe9f6f6SRyan StoneAll device-specific configuration parameters must be documented in the manual 1571fe9f6f6SRyan Stonepage for the PF driver, or in a separate manual page that is cross-referenced 1581fe9f6f6SRyan Stonefrom the main driver manual page. 1591fe9f6f6SRyan Stone.Pp 1601fe9f6f6SRyan StoneIt is not necessary for a PF driver to check for failure from any of these 1611fe9f6f6SRyan Stonefunctions. 1621fe9f6f6SRyan StoneIf an error occurs, it is flagged in the schema. 1631fe9f6f6SRyan StoneThe 1641fe9f6f6SRyan Stone.Xr pci_iov_attach 9 1651fe9f6f6SRyan Stonefunction checks for this error and will fail to initialize SR-IOV on the PF 1661fe9f6f6SRyan Stonedevice if an error is set in the schema. 1671fe9f6f6SRyan StoneIf this occurs, it is recommended that the PF driver still succeed in attaching 1681fe9f6f6SRyan Stoneand run with SR-IOV disabled on the device. 1691fe9f6f6SRyan Stone.Pp 1701fe9f6f6SRyan StoneThe 1711fe9f6f6SRyan Stone.Fn pci_iov_schema_alloc_node 1721fe9f6f6SRyan Stonefunction is used to allocate an empty configuration schema. 1731fe9f6f6SRyan StoneIt is not necessary to check for failure from this function. 1741fe9f6f6SRyan StoneThe SR-IOV infrastructure will gracefully handle failure to allocate a schema 1751fe9f6f6SRyan Stoneand will simply not enable SR-IOV on the PF device. 1761fe9f6f6SRyan Stone.Pp 1771fe9f6f6SRyan StoneThe 1781fe9f6f6SRyan Stone.Fn pci_iov_schema_add_bool 1791fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 1801fe9f6f6SRyan Stonethe name 1811fe9f6f6SRyan Stone.Pa name 1821fe9f6f6SRyan Stoneand having a boolean type. 1831fe9f6f6SRyan StoneBoolean values can only take the value true or false (1 or 0, respectively). 1841fe9f6f6SRyan Stone.Pp 1851fe9f6f6SRyan StoneThe 1861fe9f6f6SRyan Stone.Fn pci_iov_schema_add_string 1871fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 1881fe9f6f6SRyan Stonethe name 1891fe9f6f6SRyan Stone.Pa name 1901fe9f6f6SRyan Stoneand having a string type. 1911fe9f6f6SRyan StoneString values are standard C strings. 1921fe9f6f6SRyan Stone.Pp 1931fe9f6f6SRyan StoneThe 1941fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint8 1951fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 1961fe9f6f6SRyan Stonethe name 1971fe9f6f6SRyan Stone.Pa name 1981fe9f6f6SRyan Stoneand having a 1991fe9f6f6SRyan Stone.Vt uint8_t 2001fe9f6f6SRyan Stonetype. 2011fe9f6f6SRyan StoneValues of type 2021fe9f6f6SRyan Stone.Vt uint8_t 2031fe9f6f6SRyan Stoneare unsigned integers in the range 0 to 255, inclusive. 2041fe9f6f6SRyan Stone.Pp 2051fe9f6f6SRyan StoneThe 2061fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint16 2071fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 2081fe9f6f6SRyan Stonethe name 2091fe9f6f6SRyan Stone.Pa name 2101fe9f6f6SRyan Stoneand having a 2111fe9f6f6SRyan Stone.Vt uint16_t 2121fe9f6f6SRyan Stonetype. 2131fe9f6f6SRyan StoneValues of type 2141fe9f6f6SRyan Stone.Vt uint16_t 2151fe9f6f6SRyan Stoneare unsigned integers in the range 0 to 65535, inclusive. 2161fe9f6f6SRyan Stone.Pp 2171fe9f6f6SRyan StoneThe 2181fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint32 2191fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 2201fe9f6f6SRyan Stonethe name 2211fe9f6f6SRyan Stone.Pa name 2221fe9f6f6SRyan Stoneand having a 2231fe9f6f6SRyan Stone.Vt uint32_t 2241fe9f6f6SRyan Stonetype. 2251fe9f6f6SRyan StoneValues of type 2261fe9f6f6SRyan Stone.Vt uint32_t 2271fe9f6f6SRyan Stoneare unsigned integers in the range 0 to 228*fe3ff217SPatrick Kelsey.Pq 2**32 - 1 , 2291fe9f6f6SRyan Stoneinclusive. 2301fe9f6f6SRyan Stone.Pp 2311fe9f6f6SRyan StoneThe 2321fe9f6f6SRyan Stone.Fn pci_iov_schema_add_uint64 2331fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 2341fe9f6f6SRyan Stonethe name 2351fe9f6f6SRyan Stone.Pa name 2361fe9f6f6SRyan Stoneand having a 2371fe9f6f6SRyan Stone.Vt uint64_t 2381fe9f6f6SRyan Stonetype. 2391fe9f6f6SRyan StoneValues of type 2401fe9f6f6SRyan Stone.Vt uint64_t 2411fe9f6f6SRyan Stoneare unsigned integers in the range 0 to 242*fe3ff217SPatrick Kelsey.Pq 2**64 - 1 , 2431fe9f6f6SRyan Stoneinclusive. 2441fe9f6f6SRyan Stone.Pp 2451fe9f6f6SRyan StoneThe 2461fe9f6f6SRyan Stone.Fn pci_iov_schema_add_unicast_mac 2471fe9f6f6SRyan Stonefunction is used to specify a configuration parameter in the given schema with 2481fe9f6f6SRyan Stonethe name 2491fe9f6f6SRyan Stone.Pa name 2501fe9f6f6SRyan Stoneand having a unicast-mac type. 2511fe9f6f6SRyan StoneValues of type unicast-mac are binary values exactly 6 bytes long. 2521fe9f6f6SRyan StoneThe MAC address is guaranteed to not be a multicast or broadcast address. 2531fe9f6f6SRyan Stone.Sh RETURN VALUES 2541fe9f6f6SRyan StoneThe 2551fe9f6f6SRyan Stone.Fn pci_iov_schema_alloc_node 2561fe9f6f6SRyan Stonefunction returns a pointer to the allocated schema, or NULL if a failure occurs. 2571fe9f6f6SRyan Stone.Sh SEE ALSO 2581fe9f6f6SRyan Stone.Xr pci 9 , 259f3bb9251SJohn Baldwin.Xr PCI_IOV_ADD_VF 9 , 260f3bb9251SJohn Baldwin.Xr PCI_IOV_INIT 9 2611fe9f6f6SRyan Stone.Sh AUTHORS 2621fe9f6f6SRyan StoneThis manual page was written by 2631fe9f6f6SRyan Stone.An Ryan Stone Aq rstone@FreeBSD.org . 264