PCI_IOV_SCHEMA(9)
β¨ NAME β¨
okay so bestie, welcome to pci_iov_schema π β this is the PCI SR-IOV config schema interface, and honestly it's giving "build a lil blueprint for your device settings" energy. The whole squad of functions is:
pci_iov_schemapci_iov_schema_alloc_nodepci_iov_schema_add_boolpci_iov_schema_add_stringpci_iov_schema_add_uint8pci_iov_schema_add_uint16pci_iov_schema_add_uint32pci_iov_schema_add_uint64pci_iov_schema_add_unicast_mac
(It lives in the Kernel Developer's Manual, section 9, iykyk π«Ά)
πΈ SYNOPSIS πΈ
First you gotta include the lore:
#include <machine/stdarg.h>
#include <sys/nv.h>
#include <sys/iov_schema.h>
Then the whole cast of characters:
nvlist_t *
pci_iov_schema_alloc_node(void);
void
pci_iov_schema_add_bool(nvlist_t *schema, const char *name,
uint32_t flags, int defaultVal);
void
pci_iov_schema_add_string(nvlist_t *schema, const char *name,
uint32_t flags, const char *defaultVal);
void
pci_iov_schema_add_uint8(nvlist_t *schema, const char *name,
uint32_t flags, uint8_t defaultVal);
void
pci_iov_schema_add_uint16(nvlist_t *schema, const char *name,
uint32_t flags, uint16_t defaultVal);
void
pci_iov_schema_add_uint32(nvlist_t *schema, const char *name,
uint32_t flags, uint32_t defaultVal);
void
pci_iov_schema_add_uint64(nvlist_t *schema, const char *name,
uint32_t flags, uint64_t defaultVal);
void
pci_iov_schema_add_unicast_mac(nvlist_t *schema, const char *name,
uint32_t flags, const uint8_t *defaultVal);
π DESCRIPTION π
So the PCI Single-Root I/O Virtualization (SR-IOV) configuration schema? It's literally just a data structure that describes the device-specific config parameters a PF driver will accept once SR-IOV is enabled on the PF device. Main character behavior tbh π
Every PF driver defines two schema instances:
- the PF schema β describes config that applies to the PF device as a whole
- the VF schema β describes config that applies to an individual VF device
And bestie, different VF devices can totally have different config applied to them, as long as each VF's config conforms to the VF schema. Slay. β¨
A PF driver builds a config schema by first allocating a schema node, then adding configuration parameter specifications to the schema. Each parameter spec = a name + a value type. Simple as that.
Config parameter names are case-insensitive. And it is an error to specify two or more config parameters with the same name. It's also an error to specify a config parameter that uses the same name as one used by the SR-IOV infrastructure itself. Peep iovctl.conf(5) for the docs on every config parameter the SR-IOV infrastructure uses. π
The parameter type constrains the possible values that config parameter can take. That's the whole point, bestie.
π«Ά required vs default (the flag drama)
A config parameter can be marked as required by setting the IOV_SCHEMA_REQUIRED flag in the flags argument. Required parameters must be specified by the user when SR-IOV is enabled. If the user forgets? The SR-IOV infrastructure will abort the request to enable SR-IOV and return an error to the user. no cap.
Alternatively, a config parameter can be given a default value by setting the IOV_SCHEMA_HASDEFAULT flag in the flags argument. If a parameter has a default value but the user never specified one, the SR-IOV infrastructure will apply defaultVal for that parameter in the config before passing it to the PF driver. And listen β it is an error for the value of the defaultVal parameter to not conform to the restrictions of the specified type. If this flag isn't set, then the defaultVal argument is just ignored. Also IOV_SCHEMA_HASDEFAULT is not compatible with IOV_SCHEMA_REQUIRED β it's an error to specify both on the same parameter. pick a lane bestie π
The SR-IOV infrastructure guarantees that all config parameters that are either specified as required or given a default value will be present in the config passed to the PF driver. Config parameters that are neither required nor given a default are optional β they may or may not show up in the config passed to the PF driver. π€·
It is highly recommended that a PF driver reserve the use of optional parameters for configuration that is truly optional.
Example time (and this one's iconic):
- Say a Network Interface PF device has the option to encapsulate all traffic to and from a VF device in a vlan tag. The PF driver could expose that as a
"vlan"parameter accepting an integer argument specifying the vlan tag. In this case it would be appropriate to set the"vlan"parameter as an optional parameter, since it would be legitimate for a VF to be configured with no vlan tagging enabled at all. vibe check: passed β - But flip it: if the PF device had a boolean option controlling whether the VF was allowed to change its MAC address, that would not be appropriate to set as optional. The PF driver must either allow the MAC to change or not β so it'd be more appropriate to document the default behaviour by specifying a default value in the schema (or potentially force the user to make the choice by setting the parameter to be required). periodt.
Config parameters that have security implications must default to the most secure configuration possible. π do not play with this one.
Also, all device-specific config parameters must be documented in the manual page for the PF driver, or in a separate manual page that's cross-referenced from the main driver manual page. docs or it didn't happen π
π the "don't bother checking" part
It is not necessary for a PF driver to check for failure from any of these functions. If an error occurs, it's flagged in the schema. The pci_iov_attach(9) function checks for this error and will fail to initialize SR-IOV on the PF device if an error is set in the schema. If that happens, it's recommended that the PF driver still succeed in attaching and run with SR-IOV disabled on the device. graceful queen energy π
π§ the functions themselves
pci_iov_schema_alloc_node()β allocates an empty configuration schema. You don't need to check for failure here either. The SR-IOV infrastructure will gracefully handle failure to allocate a schema and will simply not enable SR-IOV on the PF device.pci_iov_schema_add_bool()β specifies a config parameter in the given schema with the name name and a boolean type. Boolean values can only betrueorfalse(1or0, respectively).pci_iov_schema_add_string()β specifies a config parameter in the given schema with the name name and a string type. String values are standard C strings.pci_iov_schema_add_uint8()β specifies a config parameter in the given schema with the name name and auint8_ttype. Values of typeuint8_tare unsigned integers in the range0to255, inclusive.pci_iov_schema_add_uint16()β specifies a config parameter in the given schema with the name name and auint16_ttype. Values of typeuint16_tare unsigned integers in the range0to65535, inclusive.pci_iov_schema_add_uint32()β specifies a config parameter in the given schema with the name name and auint32_ttype. Values of typeuint32_tare unsigned integers in the range0to(2**32 - 1), inclusive.pci_iov_schema_add_uint64()β specifies a config parameter in the given schema with the name name and auint64_ttype. Values of typeuint64_tare unsigned integers in the range0to(2**64 - 1), inclusive.pci_iov_schema_add_unicast_mac()β specifies a config parameter in the given schema with the name name and aunicast-mactype. Values of typeunicast-macare binary values exactly6bytes long. The MAC address is guaranteed to not be a multicast or broadcast address. π¦
β RETURN VALUES β
pci_iov_schema_alloc_node()β returns a pointer to the allocated schema, orNULLif a failure occurs.
π¦ SEE ALSO π¦
π AUTHORS π
This manual page was written by Ryan Stone <rstone@FreeBSD.org>. π
okay that's the whole page bestie, go forth and schema π«Άβ¨
Debian β’ July 8, 2015 β’ PCI_IOV_SCHEMA(9) β mwah, that's the version and date, ty for coming to my ted talk π
π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2014 Sandvine Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms