> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/pci_iov_add_vf.9.md).

# PCI\_IOV\_ADD\_VF.9

`PCI_IOV_ADD_VF` — 通知 PF 驱动程序正在创建 VF

## 名称

`PCI_IOV_ADD_VF`

## 概要

```c
#include <sys/bus.h>
#include <sys/stdarg.h>
#include <sys/nv.h>
#include <dev/pci/pci_iov.h>

int
PCI_IOV_ADD_VF(device_t dev, uint16_t vfnum, const nvlist_t *vf_config)
```

## 描述

`PCI_IOV_ADD_VF` 方法由 PCI 单根 I/O 虚拟化（SR-IOV）基础设施在初始化一个新的虚拟功能（VF）作为给定物理功能（PF）设备的子设备时调用。在成功调用 [PCI\_IOV\_INIT(9)](/man/man9/pci_iov_init.9.md) 之前不会调用此方法。不保证在成功调用 [PCI\_IOV\_INIT(9)](/man/man9/pci_iov_init.9.md) 之后一定会调用此方法。如果基础设施在调用 [PCI\_IOV\_INIT(9)](/man/man9/pci_iov_init.9.md) 之后遇到资源分配失败，VF 的创建将被中止，并且将立即调用 [PCI\_IOV\_UNINIT(9)](/man/man9/pci_iov_uninit.9.md)，而不会在此之前调用任何 `PCI_IOV_ADD_VF`。

正在初始化的 VF 的索引通过 `vfnum` 参数传递。VF 始终从 0 开始按顺序编号。

如果驱动程序在其对 pci\_iov\_attach(9) 的调用中通过 VF 模式请求了设备特定的配置参数，这些参数将包含在 `vf_config` 参数中。在 VF 模式中设置为必需参数或设置了默认值的所有配置参数都保证存在于 `vf_config` 中。既未设置为必需也未设置默认值的配置参数是可选的，可能存在于 `vf_config` 中，也可能不存在。`vf_config` 不会包含未在 VF 模式中指定的任何配置参数。所有配置参数都将具有正确的类型，并且位于模式中指定的有效值范围内。

注意，用户可能会在同一 PF 的不同 VF 子设备上设置不同的配置值。PF 驱动程序不得缓存先前对其他 VF 调用 `PCI_IOV_ADD_VF` 时传递的配置参数，并将这些参数应用于当前 VF。

在未先依次调用 [PCI\_IOV\_UNINIT(9)](/man/man9/pci_iov_uninit.9.md) 和 [PCI\_IOV\_INIT(9)](/man/man9/pci_iov_init.9.md) 的情况下，不会对同一 PF 设备上的同一 `vf_num` 调用此函数两次。

## 返回值

此方法成功时返回 0，否则返回适当的错误。如果此方法返回错误，则当前 VF 设备将被销毁，但其余 VF 设备将被创建，并且将在 PF 上启用 SR-IOV。

## 参见

[nv(9)](/man/man9/nv.9.md), [pci(9)](/man/man9/pci.9.md), [PCI\_IOV\_INIT(9)](/man/man9/pci_iov_init.9.md), [pci\_iov\_schema(9)](/man/man9/pci_iov_schema.9.md), [PCI\_IOV\_UNINIT(9)](/man/man9/pci_iov_uninit.9.md)

## 作者

本手册页由 Ryan Stone <rstone@FreeBSD.org> 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/pci_iov_add_vf.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
